patchwork_csv_utils 0.1.4-arm64-darwin → 0.1.5-arm64-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: f2ad80848ade16844e3fca6c549a43738f7ac7a40241073725ce7bdc0ecdcf25
4
- data.tar.gz: 4dd8f233d6c0716064365cfcb9b565acdc9169b5a02ea3482375c26d24f72d29
3
+ metadata.gz: ccdea0ba6abfc936797f007183000983de9b15b9c195dfcdcfcd6ed3e63b5119
4
+ data.tar.gz: af20ff750dbbf82f86a3aaad20242770e1327db98218dd5e93381f3627f744bb
5
5
  SHA512:
6
- metadata.gz: 23babd70402e83a357c685a6a16d5a6b3e4b0eed3dbee34ec274865fd223bceb0fbc9cb96985399abdd4ec9c6ad465f5d22541ed0807cb74208c53a2618435aa
7
- data.tar.gz: 710b787a80d6e73c5c242330fa2864c7f0201799227536e4691e61b1a1bd689f21b855f176d65baf2ebfd65ec5177ddb8d2fa8d8c0ef91f7506e4c2ef05f3b36
6
+ metadata.gz: d134cfdfafab51d74fef17480c0aad78c1033d0fc3ae443cd57ad5ce838a76fdf44a05970c295177eb6b9b26f556c2d37a8a2b04f05d67fec194f22991da8628
7
+ data.tar.gz: dc188247d6c270c0640f3f3b88173b4e3ff97d23c4b077749219fcf33c0394616b1b95b3d22e9fd5126fb2741f72bea316c1d0f09a7798484e775663661c0daa
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: arm64-darwin
6
6
  authors:
7
7
  - kingsley.hendrickse