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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc87e9b60715e648c97c91c1bbe562eb72a6fd964782abf3f1468588c053537b
4
- data.tar.gz: c368dda5d1b829a6dff9ac934e42b716c8c704d3a4605f8c4b195d1a10bcc94e
3
+ metadata.gz: d21af111b4ae04f90e8462cfbfc55fe7a61c3181bd095f2bc6e77f19bda30f9d
4
+ data.tar.gz: 0bb483d5fa060b077908e26795a3e62288931f14974b10dbfb34608ca4c6f981
5
5
  SHA512:
6
- metadata.gz: f8ead05ff26fcb2540403bcb47e5eacad33fcacf58f65ff48442406d0556f6dc5a23164258303a779a718ebc6bd8d232f6bad93d20d49275da05988bb0cc39c1
7
- data.tar.gz: f5c9d16c15fc3af24947cb1aeb122962f26483cfba282a6676b1a47c8ecc9504952785898a0c94c771520b60fc3fbc84f3453c76ba9ebd896f0e19e546b23f69
6
+ metadata.gz: d81a50d94a11e97a481c081cf5ca1e7428ecee3c0815d5c6a1305f5d3cdab2110a880cb4dfd03a930feacd3558a34cac531a0ae85e9045d4826ce64e9a5c1f11
7
+ data.tar.gz: e38f2ba7976c2535a860f1315afe4417974a72d55ed60e9104eda9b41cab9122473116b50b91375396020d3a153e8b4722754bb1a0f4a010bbc68bb30938efa2
@@ -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}"
@@ -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)))
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'csv-utils'
5
- s.version = '0.3.5'
5
+ s.version = '0.3.6'
6
6
  s.licenses = ['MIT']
7
7
  s.summary = 'CSV Utils'
8
8
  s.description = 'Tools for debugging malformed CSV files'
@@ -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.5
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-07-28 00:00:00.000000000 Z
11
+ date: 2020-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inheritance-helper