csv-utils 0.3.16 → 0.3.18

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: cda417e397f1791d177bb6eadd107edfdcd31a6680a3d2fef07b5be6df91dd6c
4
- data.tar.gz: 7dee11a2b59738a8ad1ea9f692ef2da6472bab65039fbeed630c34d369a952c0
3
+ metadata.gz: cfcbc7a92377a1b5d4dec01847defb5a4b2ac76c3dc65f40ec113c9d2085d2c6
4
+ data.tar.gz: bff2e91650ff90feb08e960ab3356d70486759aca7e4ddf54020081d31f2ce18
5
5
  SHA512:
6
- metadata.gz: af9f536d693cdcac8db949cbec1981b38637149927910b59aa570becef637cbae54c5371bc9d6031698c993e536c063b0ba89a0ca1be6c6d6ca7056e4326cc83
7
- data.tar.gz: f48853f7756f3a7e36c34e37fd38ce611db880fb5e083340eedf817800f094dcd7900b89f3f7edab2eb8eac6e2c837e9209ec3dba1cc79d95d2f065f36b15d45
6
+ metadata.gz: 7d7db74ed5c52d058fabe0498f9404915c398826be471b8407f839a9eec89c64d797cc9b9f8f1751b89ccd1b80c14165190ec50f595e942f9f0fbc151f544985
7
+ data.tar.gz: 90578cb216ba3d5260304a8cd9302bcae3e8b8e892592f7adc75db7536652822e0c729e57a074a99d77472751bfa0c92e2470be0bd7c68393ece4a782e93eb2b
data/bin/csv-diff CHANGED
@@ -104,7 +104,7 @@ end
104
104
 
105
105
  stats = Hash.new(0)
106
106
  puts "comparing #{ARGV[0]} with #{ARGV[1]}"
107
- diff_file_name = 'diff-results-' + ARGV[0]
107
+ diff_file_name = 'diff-results-' + File.basename(ARGV[0])
108
108
  CSV.open(diff_file_name, 'wb') do |out|
109
109
  out << ['Result'] + csv1.first.keys
110
110
  comparer.compare(csv2_sorted_file_name) do |action, record|
data/csv-utils.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'csv-utils'
5
- s.version = '0.3.16'
5
+ s.version = '0.3.18'
6
6
  s.licenses = ['MIT']
7
7
  s.summary = 'CSV Utils'
8
8
  s.description = 'Tools for debugging malformed CSV files'
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  # CSVUtils::CSVCompare purpose is to determine which rows in the secondary_data_file need to be created, deleted or updated
4
2
  # **requires both CSV files to be sorted on the same columns, CSVUtils::CSVSort can accomplish this
5
3
  # In order to receive updates, update_comparison_columns must configured or use inheritance and change the update_row? method
@@ -19,10 +17,12 @@ class CSVUtils::CSVCompare
19
17
  end
20
18
 
21
19
  def compare(secondary_data_file)
22
- src = CSV.open(primary_data_file)
20
+ src = CSV.open(primary_data_file, 'rb')
23
21
  src_headers = src.shift
24
- dest = CSV.open(secondary_data_file)
22
+ strip_bom!(src_headers[0])
23
+ dest = CSV.open(secondary_data_file, 'rb')
25
24
  dest_headers = dest.shift
25
+ strip_bom!(dest_headers[0])
26
26
 
27
27
  read_next_src = true
28
28
  read_next_dest = true
@@ -80,4 +80,8 @@ class CSVUtils::CSVCompare
80
80
 
81
81
  false
82
82
  end
83
+
84
+ def strip_bom!(col)
85
+ col.sub!("\xEF\xBB\xBF".force_encoding('ASCII-8BIT'), '')
86
+ end
83
87
  end
@@ -66,6 +66,16 @@ 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
+
69
79
  private
70
80
 
71
81
  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.16
4
+ version: 0.3.18
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-09-15 00:00:00.000000000 Z
11
+ date: 2022-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inheritance-helper