patchwork_csv_utils 0.1.4-x86_64-linux → 0.1.5-x86_64-linux

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: b9d62eb73016a46a3ec9caac2d43fd5db562a0856831c7f0e544e9c570e8d550
4
- data.tar.gz: 1262e0f45c2b8cfe896be3d4bd6f1074db61aa2b252049f5090cec5feba05c1a
3
+ metadata.gz: 7db641e3c590f814c0a9b89a555da4b4b333cfccdcc11759a9cd1a7faa9f6638
4
+ data.tar.gz: 2ba2941e6384563b6a44fafb715940ead548aadbc319466ed316911f7ca18148
5
5
  SHA512:
6
- metadata.gz: 4fca3c59b6ff0b5cfd1dcc2ad0ae6efdf8005716980c0a1d111bff0190a4fae3c9bc6b560086416c794be89e3eab46ae6ffc34bdfc408a806c4ac07fe1660608
7
- data.tar.gz: 28454948d621cd2272b9a6790d735ce7e2d95da51202accb76a3d56f1a5b2b6bc9a274bf7473073bbc99fac25a64de818ed0a1b9839b94dc0893241ff0290c24
6
+ metadata.gz: 2856df18a42dc6019c3a6b6d02aa9d88ccd6384ac46a157bc762c4848dd601bd1a31dd072831bd8dafe301ab8514c930bbff159f7f22a47aeb8ff0aafbd932ee
7
+ data.tar.gz: 926f5673c06e7419f63ff66094e2c35d7aae36df5b8eb09f3604ea4ee77add83b36bf8087f36ffe495e00b728a5052277738f11da3037260484aeb2232086be7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patchwork_csv_utils (0.1.4)
4
+ patchwork_csv_utils (0.1.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -33,12 +33,20 @@ pub fn dedup(ruby: &Ruby, previous_csv_path: String, new_csv_path: String, targe
33
33
  let mut previous_records = vec![];
34
34
  for previous_record in previous_csv.records() {
35
35
  let previous_record = previous_record.map_err(|e| magnus_err(ruby, e, "previous_record"))?;
36
+
37
+ if has_empty_row_skip(&previous_record) { continue; }
38
+ if has_empty_first_col_skip_row(&previous_record) { continue; }
39
+
36
40
  let previous_record = previous_record.into_iter().map(|r| r.trim_end()).collect::<StringRecord>();
37
41
  previous_records.push(previous_record)
38
42
  }
39
43
 
40
44
  for new_record in new_csv.records() {
41
45
  let new_record = new_record.map_err(|e| magnus_err(ruby, e, "new_record"))?;
46
+
47
+ if has_empty_row_skip(&new_record) { continue; }
48
+ if has_empty_first_col_skip_row(&new_record) { continue; }
49
+
42
50
  let new_record = new_record.into_iter().map(|r| r.trim_end()).collect::<StringRecord>();
43
51
  if !previous_records.contains(&new_record) {
44
52
  wtr.write_byte_record(new_record.as_byte_record()).unwrap();
@@ -50,4 +58,18 @@ pub fn dedup(ruby: &Ruby, previous_csv_path: String, new_csv_path: String, targe
50
58
  Ok(())
51
59
  }
52
60
 
61
+ fn has_empty_first_col_skip_row(previous_record: &StringRecord) -> bool {
62
+ if previous_record[0].is_empty() {
63
+ return true;
64
+ }
65
+ false
66
+ }
67
+
68
+ fn has_empty_row_skip(record: &StringRecord) -> bool {
69
+ if record.iter().all(|r| r.is_empty()) {
70
+ return true;
71
+ }
72
+ false
73
+ }
74
+
53
75
 
Binary file
Binary file
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CsvUtils
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patchwork_csv_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - kingsley.hendrickse