patchwork_csv_utils 0.1.4-x86_64-darwin → 0.1.5-x86_64-darwin

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: 3c6776e830a462f49749ef223d12ae26fa218c1f05dd3d6e5dd45ab814ea9b00
4
- data.tar.gz: ef8b2c7b2e15701c18f5ab5382ba95ac8419b2e22b4af5e9973cedb9fe812148
3
+ metadata.gz: 53bd775b8a062a5418959e170dce922799739ebbf4a4845eb48f65e889ae4fff
4
+ data.tar.gz: 26e9f478dd57a8a9307b4536e242af967145c688ae9e4f4002655da86f8405cc
5
5
  SHA512:
6
- metadata.gz: 033761efc132f629f3eab8c9946ba470cc0a73b35402281eac75927cadb39d898d7a955993b3e1cd1393a8d7e5dad36d005aefec9a6e9f7fc93e87fa64389134
7
- data.tar.gz: d9f2a12777a9e9541e6ab6e8056964f2cf1b0c3e98454dc8083de2d2336e9b5097367cd998c98a4cfaa065f1a122bc28f63d06ce050dfcd42a8992a5a8b87a38
6
+ metadata.gz: 256012cce7a6b5802c9ab05fe1e9063e7d99f63fa83f3f011f8375698a5abb1897312776c333fd9757e17c20b7674aff9b9997c3519effb39f9833be2be3f8e9
7
+ data.tar.gz: 6ce45dcb2f95347350f6272fc8b0c4b84e0b8d24bd773d86b40e9b370de334839773c2363be1ef55e6809d6f510f19bfd25ebecdc669dd65dbb61a8aaa91b172
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-darwin
6
6
  authors:
7
7
  - kingsley.hendrickse