csv-utils 0.3.16 → 0.3.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/csv-diff +1 -1
- data/csv-utils.gemspec +1 -1
- data/lib/csv_utils/csv_compare.rb +8 -4
- data/lib/csv_utils/csv_iterator.rb +10 -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: cfcbc7a92377a1b5d4dec01847defb5a4b2ac76c3dc65f40ec113c9d2085d2c6
|
4
|
+
data.tar.gz: bff2e91650ff90feb08e960ab3356d70486759aca7e4ddf54020081d31f2ce18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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
|
-
|
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
|
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.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-
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inheritance-helper
|