csv-utils 0.3.17 → 0.3.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/csv-utils.gemspec +1 -1
- data/lib/csv_utils/csv_iterator.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 440e96f112e783fee10a1649cb0a115ee9b0403dc7696a20bb7d0c79fd212006
|
4
|
+
data.tar.gz: de3664cf9e7106693085d87a7f828b11f92118750183cb52bff4ecd6d585308d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92051057bddc10ad33fd227234088f1cb54f11fe4dba4fcee96db45ca9f8f2327d4923719fd9b7cf741b1914a38014c2a3a5e7efddd3c70f2440935f27dc508d
|
7
|
+
data.tar.gz: f1f4eefcdba39c7ae758b2d82a58e4ac578509473458ed7d1efbd7f0fa73b479c90fbdf58bde49ec507927c4fbfef44f00b12a3b9f4268de5aac5d30c8ba4e70
|
data/csv-utils.gemspec
CHANGED
@@ -66,6 +66,34 @@ class CSVUtils::CSVIterator
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def size
|
70
|
+
@src_csv.rewind
|
71
|
+
@src_csv.shift
|
72
|
+
cnt = 0
|
73
|
+
while @src_csv.shift
|
74
|
+
cnt +=1
|
75
|
+
end
|
76
|
+
cnt
|
77
|
+
end
|
78
|
+
|
79
|
+
def each_batch(batch_size = 1_000)
|
80
|
+
batch = []
|
81
|
+
|
82
|
+
process_batch_proc = Proc.new do
|
83
|
+
yield batch
|
84
|
+
batch = []
|
85
|
+
end
|
86
|
+
|
87
|
+
each do |row|
|
88
|
+
batch << row
|
89
|
+
process_batch_proc.call if batch.size >= batch_size
|
90
|
+
end
|
91
|
+
|
92
|
+
process_batch_proc.call if batch.size > 0
|
93
|
+
|
94
|
+
nil
|
95
|
+
end
|
96
|
+
|
69
97
|
private
|
70
98
|
|
71
99
|
def strip_bom!(col)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inheritance-helper
|