csv-utils 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/csv-find-error +3 -1
- data/bin/csv-validator +1 -1
- data/csv-utils.gemspec +1 -1
- data/lib/csv_utils/csv_iterator.rb +4 -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: d21af111b4ae04f90e8462cfbfc55fe7a61c3181bd095f2bc6e77f19bda30f9d
|
4
|
+
data.tar.gz: 0bb483d5fa060b077908e26795a3e62288931f14974b10dbfb34608ca4c6f981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d81a50d94a11e97a481c081cf5ca1e7428ecee3c0815d5c6a1305f5d3cdab2110a880cb4dfd03a930feacd3558a34cac531a0ae85e9045d4826ce64e9a5c1f11
|
7
|
+
data.tar.gz: e38f2ba7976c2535a860f1315afe4417974a72d55ed60e9104eda9b41cab9122473116b50b91375396020d3a153e8b4722754bb1a0f4a010bbc68bb30938efa2
|
data/bin/csv-find-error
CHANGED
@@ -3,10 +3,12 @@
|
|
3
3
|
require 'csv'
|
4
4
|
require 'shellwords'
|
5
5
|
|
6
|
+
prev_row = nil
|
6
7
|
begin
|
7
|
-
CSV.open(ARGV[0], 'rb').each { }
|
8
|
+
CSV.open(ARGV[0], 'rb').each { |row| prev_row = row }
|
8
9
|
rescue CSV::MalformedCSVError => e
|
9
10
|
puts e.class.to_s + ': ' + e.message
|
11
|
+
puts "previous row was #{prev_row}"
|
10
12
|
if e.message =~ /line (\d+)/
|
11
13
|
lineno = $1.to_i
|
12
14
|
cmd = "csv-readline #{Shellwords.escape(ARGV[0])} #{lineno}"
|
data/bin/csv-validator
CHANGED
@@ -61,7 +61,7 @@ while (row = csv.shift)
|
|
61
61
|
end
|
62
62
|
|
63
63
|
row.each_with_index do |col, idx|
|
64
|
-
next if utf8?(col)
|
64
|
+
next if col.nil? || utf8?(col)
|
65
65
|
|
66
66
|
$stderr.puts "row(#{csv_lineno}),col(#{idx + 1}) #{headers[idx]}: none UTF-8 characters found in \"#{col}\""
|
67
67
|
if (col_utf8_encoded = convert_to_utf8(col, detect_encoding(col)))
|
data/csv-utils.gemspec
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
class CSVUtils::CSVIterator
|
3
3
|
include Enumerable
|
4
4
|
|
5
|
+
attr_reader :prev_row
|
6
|
+
|
5
7
|
class RowWrapper < Hash
|
6
8
|
attr_accessor :lineno
|
7
9
|
|
@@ -33,9 +35,11 @@ class CSVUtils::CSVIterator
|
|
33
35
|
lineno += 1
|
34
36
|
end
|
35
37
|
|
38
|
+
@prev_row = nil
|
36
39
|
while (row = @src_csv.shift)
|
37
40
|
lineno += 1
|
38
41
|
yield RowWrapper.create(headers, row, lineno)
|
42
|
+
@prev_row = row
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inheritance-helper
|