csv-validation 0.1.0__tar.gz → 0.1.2__tar.gz

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.
@@ -17,6 +17,12 @@ dependencies = [
17
17
  "memchr",
18
18
  ]
19
19
 
20
+ [[package]]
21
+ name = "anyhow"
22
+ version = "1.0.102"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
25
+
20
26
  [[package]]
21
27
  name = "arc-swap"
22
28
  version = "1.7.1"
@@ -35,6 +41,12 @@ version = "1.4.0"
35
41
  source = "registry+https://github.com/rust-lang/crates.io-index"
36
42
  checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
37
43
 
44
+ [[package]]
45
+ name = "bitflags"
46
+ version = "2.11.0"
47
+ source = "registry+https://github.com/rust-lang/crates.io-index"
48
+ checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
49
+
38
50
  [[package]]
39
51
  name = "cfg-if"
40
52
  version = "1.0.0"
@@ -83,7 +95,7 @@ dependencies = [
83
95
 
84
96
  [[package]]
85
97
  name = "csv_validation"
86
- version = "0.1.0"
98
+ version = "0.1.2"
87
99
  dependencies = [
88
100
  "csv",
89
101
  "flate2",
@@ -94,6 +106,7 @@ dependencies = [
94
106
  "regex",
95
107
  "serde",
96
108
  "simple_logger",
109
+ "tempfile",
97
110
  "yaml-rust2",
98
111
  ]
99
112
 
@@ -115,6 +128,28 @@ dependencies = [
115
128
  "cfg-if",
116
129
  ]
117
130
 
131
+ [[package]]
132
+ name = "equivalent"
133
+ version = "1.0.2"
134
+ source = "registry+https://github.com/rust-lang/crates.io-index"
135
+ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
136
+
137
+ [[package]]
138
+ name = "errno"
139
+ version = "0.3.14"
140
+ source = "registry+https://github.com/rust-lang/crates.io-index"
141
+ checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
142
+ dependencies = [
143
+ "libc",
144
+ "windows-sys 0.59.0",
145
+ ]
146
+
147
+ [[package]]
148
+ name = "fastrand"
149
+ version = "2.3.0"
150
+ source = "registry+https://github.com/rust-lang/crates.io-index"
151
+ checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
152
+
118
153
  [[package]]
119
154
  name = "flate2"
120
155
  version = "1.1.0"
@@ -131,6 +166,19 @@ version = "0.1.4"
131
166
  source = "registry+https://github.com/rust-lang/crates.io-index"
132
167
  checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
133
168
 
169
+ [[package]]
170
+ name = "getrandom"
171
+ version = "0.4.2"
172
+ source = "registry+https://github.com/rust-lang/crates.io-index"
173
+ checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555"
174
+ dependencies = [
175
+ "cfg-if",
176
+ "libc",
177
+ "r-efi",
178
+ "wasip2",
179
+ "wasip3",
180
+ ]
181
+
134
182
  [[package]]
135
183
  name = "hashbrown"
136
184
  version = "0.15.2"
@@ -155,6 +203,23 @@ version = "0.5.0"
155
203
  source = "registry+https://github.com/rust-lang/crates.io-index"
156
204
  checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
157
205
 
206
+ [[package]]
207
+ name = "id-arena"
208
+ version = "2.3.0"
209
+ source = "registry+https://github.com/rust-lang/crates.io-index"
210
+ checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
211
+
212
+ [[package]]
213
+ name = "indexmap"
214
+ version = "2.11.1"
215
+ source = "registry+https://github.com/rust-lang/crates.io-index"
216
+ checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921"
217
+ dependencies = [
218
+ "equivalent",
219
+ "hashbrown",
220
+ "serde",
221
+ ]
222
+
158
223
  [[package]]
159
224
  name = "indoc"
160
225
  version = "2.0.6"
@@ -173,12 +238,24 @@ version = "1.5.0"
173
238
  source = "registry+https://github.com/rust-lang/crates.io-index"
174
239
  checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
175
240
 
241
+ [[package]]
242
+ name = "leb128fmt"
243
+ version = "0.1.0"
244
+ source = "registry+https://github.com/rust-lang/crates.io-index"
245
+ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
246
+
176
247
  [[package]]
177
248
  name = "libc"
178
249
  version = "0.2.178"
179
250
  source = "registry+https://github.com/rust-lang/crates.io-index"
180
251
  checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
181
252
 
253
+ [[package]]
254
+ name = "linux-raw-sys"
255
+ version = "0.11.0"
256
+ source = "registry+https://github.com/rust-lang/crates.io-index"
257
+ checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
258
+
182
259
  [[package]]
183
260
  name = "log"
184
261
  version = "0.4.26"
@@ -242,6 +319,16 @@ version = "0.2.0"
242
319
  source = "registry+https://github.com/rust-lang/crates.io-index"
243
320
  checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
244
321
 
322
+ [[package]]
323
+ name = "prettyplease"
324
+ version = "0.2.37"
325
+ source = "registry+https://github.com/rust-lang/crates.io-index"
326
+ checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
327
+ dependencies = [
328
+ "proc-macro2",
329
+ "syn",
330
+ ]
331
+
245
332
  [[package]]
246
333
  name = "proc-macro2"
247
334
  version = "1.0.94"
@@ -334,6 +421,12 @@ dependencies = [
334
421
  "proc-macro2",
335
422
  ]
336
423
 
424
+ [[package]]
425
+ name = "r-efi"
426
+ version = "6.0.0"
427
+ source = "registry+https://github.com/rust-lang/crates.io-index"
428
+ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
429
+
337
430
  [[package]]
338
431
  name = "redb"
339
432
  version = "3.1.0"
@@ -372,12 +465,31 @@ version = "0.8.5"
372
465
  source = "registry+https://github.com/rust-lang/crates.io-index"
373
466
  checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
374
467
 
468
+ [[package]]
469
+ name = "rustix"
470
+ version = "1.1.3"
471
+ source = "registry+https://github.com/rust-lang/crates.io-index"
472
+ checksum = "146c9e247ccc180c1f61615433868c99f3de3ae256a30a43b49f67c2d9171f34"
473
+ dependencies = [
474
+ "bitflags",
475
+ "errno",
476
+ "libc",
477
+ "linux-raw-sys",
478
+ "windows-sys 0.59.0",
479
+ ]
480
+
375
481
  [[package]]
376
482
  name = "ryu"
377
483
  version = "1.0.20"
378
484
  source = "registry+https://github.com/rust-lang/crates.io-index"
379
485
  checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
380
486
 
487
+ [[package]]
488
+ name = "semver"
489
+ version = "1.0.27"
490
+ source = "registry+https://github.com/rust-lang/crates.io-index"
491
+ checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
492
+
381
493
  [[package]]
382
494
  name = "serde"
383
495
  version = "1.0.218"
@@ -398,6 +510,18 @@ dependencies = [
398
510
  "syn",
399
511
  ]
400
512
 
513
+ [[package]]
514
+ name = "serde_json"
515
+ version = "1.0.143"
516
+ source = "registry+https://github.com/rust-lang/crates.io-index"
517
+ checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
518
+ dependencies = [
519
+ "itoa",
520
+ "memchr",
521
+ "ryu",
522
+ "serde",
523
+ ]
524
+
401
525
  [[package]]
402
526
  name = "simple_logger"
403
527
  version = "5.0.0"
@@ -412,9 +536,9 @@ dependencies = [
412
536
 
413
537
  [[package]]
414
538
  name = "syn"
415
- version = "2.0.99"
539
+ version = "2.0.117"
416
540
  source = "registry+https://github.com/rust-lang/crates.io-index"
417
- checksum = "e02e925281e18ffd9d640e234264753c43edc62d64b2d4cf898f1bc5e75f3fc2"
541
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
418
542
  dependencies = [
419
543
  "proc-macro2",
420
544
  "quote",
@@ -427,6 +551,19 @@ version = "0.12.16"
427
551
  source = "registry+https://github.com/rust-lang/crates.io-index"
428
552
  checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
429
553
 
554
+ [[package]]
555
+ name = "tempfile"
556
+ version = "3.25.0"
557
+ source = "registry+https://github.com/rust-lang/crates.io-index"
558
+ checksum = "0136791f7c95b1f6dd99f9cc786b91bb81c3800b639b3478e561ddb7be95e5f1"
559
+ dependencies = [
560
+ "fastrand",
561
+ "getrandom",
562
+ "once_cell",
563
+ "rustix",
564
+ "windows-sys 0.59.0",
565
+ ]
566
+
430
567
  [[package]]
431
568
  name = "time"
432
569
  version = "0.3.37"
@@ -466,12 +603,70 @@ version = "1.0.18"
466
603
  source = "registry+https://github.com/rust-lang/crates.io-index"
467
604
  checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
468
605
 
606
+ [[package]]
607
+ name = "unicode-xid"
608
+ version = "0.2.6"
609
+ source = "registry+https://github.com/rust-lang/crates.io-index"
610
+ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
611
+
469
612
  [[package]]
470
613
  name = "unindent"
471
614
  version = "0.2.4"
472
615
  source = "registry+https://github.com/rust-lang/crates.io-index"
473
616
  checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
474
617
 
618
+ [[package]]
619
+ name = "wasip2"
620
+ version = "1.0.2+wasi-0.2.9"
621
+ source = "registry+https://github.com/rust-lang/crates.io-index"
622
+ checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5"
623
+ dependencies = [
624
+ "wit-bindgen",
625
+ ]
626
+
627
+ [[package]]
628
+ name = "wasip3"
629
+ version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
630
+ source = "registry+https://github.com/rust-lang/crates.io-index"
631
+ checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
632
+ dependencies = [
633
+ "wit-bindgen",
634
+ ]
635
+
636
+ [[package]]
637
+ name = "wasm-encoder"
638
+ version = "0.244.0"
639
+ source = "registry+https://github.com/rust-lang/crates.io-index"
640
+ checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
641
+ dependencies = [
642
+ "leb128fmt",
643
+ "wasmparser",
644
+ ]
645
+
646
+ [[package]]
647
+ name = "wasm-metadata"
648
+ version = "0.244.0"
649
+ source = "registry+https://github.com/rust-lang/crates.io-index"
650
+ checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
651
+ dependencies = [
652
+ "anyhow",
653
+ "indexmap",
654
+ "wasm-encoder",
655
+ "wasmparser",
656
+ ]
657
+
658
+ [[package]]
659
+ name = "wasmparser"
660
+ version = "0.244.0"
661
+ source = "registry+https://github.com/rust-lang/crates.io-index"
662
+ checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
663
+ dependencies = [
664
+ "bitflags",
665
+ "hashbrown",
666
+ "indexmap",
667
+ "semver",
668
+ ]
669
+
475
670
  [[package]]
476
671
  name = "windows-sys"
477
672
  version = "0.48.0"
@@ -611,6 +806,94 @@ version = "0.52.6"
611
806
  source = "registry+https://github.com/rust-lang/crates.io-index"
612
807
  checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
613
808
 
809
+ [[package]]
810
+ name = "wit-bindgen"
811
+ version = "0.51.0"
812
+ source = "registry+https://github.com/rust-lang/crates.io-index"
813
+ checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
814
+ dependencies = [
815
+ "wit-bindgen-rust-macro",
816
+ ]
817
+
818
+ [[package]]
819
+ name = "wit-bindgen-core"
820
+ version = "0.51.0"
821
+ source = "registry+https://github.com/rust-lang/crates.io-index"
822
+ checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
823
+ dependencies = [
824
+ "anyhow",
825
+ "heck",
826
+ "wit-parser",
827
+ ]
828
+
829
+ [[package]]
830
+ name = "wit-bindgen-rust"
831
+ version = "0.51.0"
832
+ source = "registry+https://github.com/rust-lang/crates.io-index"
833
+ checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
834
+ dependencies = [
835
+ "anyhow",
836
+ "heck",
837
+ "indexmap",
838
+ "prettyplease",
839
+ "syn",
840
+ "wasm-metadata",
841
+ "wit-bindgen-core",
842
+ "wit-component",
843
+ ]
844
+
845
+ [[package]]
846
+ name = "wit-bindgen-rust-macro"
847
+ version = "0.51.0"
848
+ source = "registry+https://github.com/rust-lang/crates.io-index"
849
+ checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
850
+ dependencies = [
851
+ "anyhow",
852
+ "prettyplease",
853
+ "proc-macro2",
854
+ "quote",
855
+ "syn",
856
+ "wit-bindgen-core",
857
+ "wit-bindgen-rust",
858
+ ]
859
+
860
+ [[package]]
861
+ name = "wit-component"
862
+ version = "0.244.0"
863
+ source = "registry+https://github.com/rust-lang/crates.io-index"
864
+ checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
865
+ dependencies = [
866
+ "anyhow",
867
+ "bitflags",
868
+ "indexmap",
869
+ "log",
870
+ "serde",
871
+ "serde_derive",
872
+ "serde_json",
873
+ "wasm-encoder",
874
+ "wasm-metadata",
875
+ "wasmparser",
876
+ "wit-parser",
877
+ ]
878
+
879
+ [[package]]
880
+ name = "wit-parser"
881
+ version = "0.244.0"
882
+ source = "registry+https://github.com/rust-lang/crates.io-index"
883
+ checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
884
+ dependencies = [
885
+ "anyhow",
886
+ "id-arena",
887
+ "indexmap",
888
+ "log",
889
+ "semver",
890
+ "serde",
891
+ "serde_derive",
892
+ "serde_json",
893
+ "unicode-xid",
894
+ "wasmparser",
895
+ ]
896
+
614
897
  [[package]]
615
898
  name = "yaml-rust2"
616
899
  version = "0.10.0"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "csv_validation"
3
- version = "0.1.0"
3
+ version = "0.1.2"
4
4
  edition = "2021"
5
5
  readme = "README.md"
6
6
 
@@ -14,10 +14,15 @@ csv = "1.3.1"
14
14
  flate2 = "1.1.0"
15
15
  log = "0.4.26"
16
16
  # abi3-py310 makes the wheels forward-compatible with 3.11, 3.12 ...
17
- pyo3 = { version = "0.23.3", features = ["extension-module", "abi3-py310"] }
17
+ pyo3 = { version = "0.23.3", features = ["abi3-py310"] }
18
18
  pyo3-log = "0.12.1"
19
19
  regex = "1.11.1"
20
20
  simple_logger = "5.0.0"
21
21
  yaml-rust2 = "0.10.0"
22
22
  serde = { version = "1.0.218", features = ["derive"] }
23
23
  redb = "3.1.0"
24
+ tempfile = "3.10.1"
25
+
26
+ [features]
27
+ extension-module = ["pyo3/extension-module"]
28
+ default = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csv_validation
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -193,12 +193,12 @@ columns:
193
193
  What you will see in the summary:
194
194
  - Always shows the number of duplicate key groups found.
195
195
  - If there are more than 100 duplicate groups, only the first 100 are displayed as a sample (with their occurrence counts), and the total number is indicated.
196
- - If no duplicates are found, it reports: "Duplicates found: 0".
196
+ - If no duplicates are found, it reports: "No duplicates found".
197
197
 
198
198
  Sample output (composite key):
199
199
 
200
200
  ```
201
- UNIQUE KEY: column(s): ["isin", "date", "score_provider"]
201
+ UNIQUE KEY: column(s): isin, date, score_provider
202
202
 
203
203
  DUPLICATED KEYS (groups found: 134)
204
204
  --------------------------------------------------
@@ -213,7 +213,7 @@ If none:
213
213
  ```
214
214
  UNIQUE KEYS CHECK
215
215
  --------------------------------------------------
216
- - No Duplicates found
216
+ - No duplicates found
217
217
  ```
218
218
 
219
219
  Performance note: Duplicate detection stores only the unique keys on disk and keeps a tiny in-memory summary used for printing the report. This allows validating huge datasets with minimal RAM usage.
@@ -242,7 +242,7 @@ validator.set_decimal_separator(",") # Use comma
242
242
  The library provides detailed validation reports through Python's logging system. When a validation fails, you'll get information about:
243
243
  - Which columns failed validation
244
244
  - What type of validation failed
245
- - Sample of invalid values
245
+ - Sample of invalid values (including row numbers)
246
246
  - Number of rows that failed each validation
247
247
 
248
248
  ### Example of validation report
@@ -256,27 +256,27 @@ Rows: 232230 | Columns: 5
256
256
  CORRECT COLUMNS: 3/5
257
257
  --------------------------------------------------
258
258
  - County: [✔] OK
259
- ✔ - RegularExpression { expression: "^.*$", alias: "regex" }
259
+ ✔ - regex: '^.*$'
260
260
  - City: [✔] OK
261
- ✔ - RegularExpression { expression: "^.*$", alias: "regex" }
261
+ ✔ - regex: '^.*$'
262
262
  - Model Year: [✔] OK
263
- ✔ - RegularExpression { expression: "^[0-9]+$", alias: "regex" }
264
- ✔ - Min(1999.0)
265
- ✔ - Max(2025.78)
263
+ ✔ - regex: '^[0-9]+$'
264
+ ✔ - min: 1999
265
+ ✔ - max: 2025.78
266
266
 
267
267
  WRONG COLUMNS: 2/5
268
268
  --------------------------------------------------
269
269
  - State: [✖] FAIL
270
- ✖ - Values(["WA", "OR", "NY", "DC", "CA", "TX", "FL", "OK", "MO", "KS", "VA", "MA", "MO", "NC", "IL", "AL", "WY", "CO", "PA", "WI", "MD", "NV", "AZ"])
271
- "Wrong Rows: 93 | Sample: 'GA','NJ','CT','NJ','CT','CT','CT','NE','CT','NH'"
270
+ ✖ - values: 'WA', 'OR', 'NY', 'DC', 'CA', 'TX', 'FL', 'OK', 'MO', 'KS', 'VA', 'MA', 'MO', 'NC', 'IL', 'AL', 'WY', 'CO', 'PA', 'WI', 'MD', 'NV', 'AZ'
271
+ "Wrong Rows: 93 | Sample: [row 12: 'GA'], [row 15: 'NJ'], [row 22: 'CT'], [row 23: 'NJ'], [row 24: 'CT']"
272
272
  - Postal Code: [✖] FAIL
273
- ✔ - RegularExpression { expression: "^$|^-?\\d+$", alias: "integer" }
274
- ✖ - RegularExpression { expression: "^.+$", alias: "non_empty" }
275
- "Wrong Rows: 4 | Sample: '','','',''"
273
+ ✔ - integer
274
+ ✖ - non_empty
275
+ "Wrong Rows: 4 | Sample: [row 45: ''], [row 123: ''], [row 456: ''], [row 789: '']"
276
276
 
277
277
  VALIDATION RESULT
278
278
  --------------------------------------------------
279
- [✖] FAIL: File DOESN'T match all validations
279
+ [✖] FAIL: File /test.csv DOESN'T match all validations
280
280
  ```
281
281
 
282
282
  ## Development
@@ -181,12 +181,12 @@ columns:
181
181
  What you will see in the summary:
182
182
  - Always shows the number of duplicate key groups found.
183
183
  - If there are more than 100 duplicate groups, only the first 100 are displayed as a sample (with their occurrence counts), and the total number is indicated.
184
- - If no duplicates are found, it reports: "Duplicates found: 0".
184
+ - If no duplicates are found, it reports: "No duplicates found".
185
185
 
186
186
  Sample output (composite key):
187
187
 
188
188
  ```
189
- UNIQUE KEY: column(s): ["isin", "date", "score_provider"]
189
+ UNIQUE KEY: column(s): isin, date, score_provider
190
190
 
191
191
  DUPLICATED KEYS (groups found: 134)
192
192
  --------------------------------------------------
@@ -201,7 +201,7 @@ If none:
201
201
  ```
202
202
  UNIQUE KEYS CHECK
203
203
  --------------------------------------------------
204
- - No Duplicates found
204
+ - No duplicates found
205
205
  ```
206
206
 
207
207
  Performance note: Duplicate detection stores only the unique keys on disk and keeps a tiny in-memory summary used for printing the report. This allows validating huge datasets with minimal RAM usage.
@@ -230,7 +230,7 @@ validator.set_decimal_separator(",") # Use comma
230
230
  The library provides detailed validation reports through Python's logging system. When a validation fails, you'll get information about:
231
231
  - Which columns failed validation
232
232
  - What type of validation failed
233
- - Sample of invalid values
233
+ - Sample of invalid values (including row numbers)
234
234
  - Number of rows that failed each validation
235
235
 
236
236
  ### Example of validation report
@@ -244,27 +244,27 @@ Rows: 232230 | Columns: 5
244
244
  CORRECT COLUMNS: 3/5
245
245
  --------------------------------------------------
246
246
  - County: [✔] OK
247
- ✔ - RegularExpression { expression: "^.*$", alias: "regex" }
247
+ ✔ - regex: '^.*$'
248
248
  - City: [✔] OK
249
- ✔ - RegularExpression { expression: "^.*$", alias: "regex" }
249
+ ✔ - regex: '^.*$'
250
250
  - Model Year: [✔] OK
251
- ✔ - RegularExpression { expression: "^[0-9]+$", alias: "regex" }
252
- ✔ - Min(1999.0)
253
- ✔ - Max(2025.78)
251
+ ✔ - regex: '^[0-9]+$'
252
+ ✔ - min: 1999
253
+ ✔ - max: 2025.78
254
254
 
255
255
  WRONG COLUMNS: 2/5
256
256
  --------------------------------------------------
257
257
  - State: [✖] FAIL
258
- ✖ - Values(["WA", "OR", "NY", "DC", "CA", "TX", "FL", "OK", "MO", "KS", "VA", "MA", "MO", "NC", "IL", "AL", "WY", "CO", "PA", "WI", "MD", "NV", "AZ"])
259
- "Wrong Rows: 93 | Sample: 'GA','NJ','CT','NJ','CT','CT','CT','NE','CT','NH'"
258
+ ✖ - values: 'WA', 'OR', 'NY', 'DC', 'CA', 'TX', 'FL', 'OK', 'MO', 'KS', 'VA', 'MA', 'MO', 'NC', 'IL', 'AL', 'WY', 'CO', 'PA', 'WI', 'MD', 'NV', 'AZ'
259
+ "Wrong Rows: 93 | Sample: [row 12: 'GA'], [row 15: 'NJ'], [row 22: 'CT'], [row 23: 'NJ'], [row 24: 'CT']"
260
260
  - Postal Code: [✖] FAIL
261
- ✔ - RegularExpression { expression: "^$|^-?\\d+$", alias: "integer" }
262
- ✖ - RegularExpression { expression: "^.+$", alias: "non_empty" }
263
- "Wrong Rows: 4 | Sample: '','','',''"
261
+ ✔ - integer
262
+ ✖ - non_empty
263
+ "Wrong Rows: 4 | Sample: [row 45: ''], [row 123: ''], [row 456: ''], [row 789: '']"
264
264
 
265
265
  VALIDATION RESULT
266
266
  --------------------------------------------------
267
- [✖] FAIL: File DOESN'T match all validations
267
+ [✖] FAIL: File /test.csv DOESN'T match all validations
268
268
  ```
269
269
 
270
270
  ## Development
@@ -22,19 +22,6 @@ const DEFAULT_DECIMAL_SEPARATOR:char = '.';
22
22
 
23
23
  const DUPLICATES_TABLE: TableDefinition<&str, &[u8]> = TableDefinition::new("duplicates");
24
24
 
25
- // A simple guard to ensure the temp file is deleted when it goes out of scope.
26
- struct CleanupGuard {
27
- path: String,
28
- }
29
-
30
- impl Drop for CleanupGuard {
31
- fn drop(&mut self) {
32
- if Path::new(&self.path).exists() {
33
- let _ = std::fs::remove_file(&self.path);
34
- }
35
- }
36
- }
37
-
38
25
  #[derive(Debug, Clone, Serialize, Deserialize)]
39
26
  enum Validation {
40
27
  RegularExpression { expression: String, alias: String },
@@ -349,7 +336,7 @@ fn validation_for_non_empty() -> Validation {
349
336
  }
350
337
 
351
338
  fn regex_for_non_empty() -> String {
352
- String::from("^.+$")
339
+ String::from("(?s)^.+$")
353
340
  }
354
341
 
355
342
  fn validate_column_names(reader: &mut Reader<Box<dyn Read>>, validations: &Vec<ColumnValidations>) -> PyResult<bool> {
@@ -553,15 +540,17 @@ impl CSVValidator {
553
540
  }
554
541
 
555
542
  // If unique key validation is enabled, prepare a temporary redb database
556
- let mut _cleanup_guard: Option<CleanupGuard> = None;
543
+ let mut _temp_path: Option<tempfile::TempPath> = None;
557
544
  let mut redb_db: Option<Database> = None;
558
545
  let mut redb_txn: Option<redb::WriteTransaction> = None;
559
546
  if unique_key_indices.is_some() {
560
- let db_path = "_temp_redb.db";
561
- _cleanup_guard = Some(CleanupGuard { path: db_path.to_string() });
562
- let db = Database::create(db_path).map_err(|e| PyRuntimeError::new_err(format!("Failed to open redb: {}", e)))?;
547
+ let temp_path = tempfile::NamedTempFile::new()
548
+ .map_err(|e| PyRuntimeError::new_err(format!("Failed to create temp file to check unique keys: {}", e)))?
549
+ .into_temp_path();
550
+ let db = Database::create(&temp_path).map_err(|e| PyRuntimeError::new_err(format!("Failed to open redb: {}", e)))?;
563
551
  let write_txn = db.begin_write().map_err(|e| PyRuntimeError::new_err(format!("Failed to begin transaction: {}", e)))?;
564
552
  redb_txn = Some(write_txn);
553
+ _temp_path = Some(temp_path);
565
554
  redb_db = Some(db);
566
555
  }
567
556
 
@@ -934,6 +923,27 @@ mod tests {
934
923
  assert!(!validator.validate("test/empty_values.csv").unwrap());
935
924
  }
936
925
 
926
+ #[test]
927
+ fn test_non_empty_with_multiline_value() {
928
+ use std::fs;
929
+ let definition = String::from("
930
+ columns:
931
+ - name: ColumnA
932
+ extra: non_empty
933
+ ");
934
+
935
+ let path_of_file_to_validate = "test/test_multiline_non_empty.csv";
936
+ let file_content = "ColumnA\n\"line1\nline2\"";
937
+ fs::write(path_of_file_to_validate, file_content).unwrap();
938
+
939
+ let validator = CSVValidator::from_string(&definition).unwrap();
940
+ let result = validator.validate(path_of_file_to_validate).unwrap();
941
+
942
+ fs::remove_file(path_of_file_to_validate).unwrap();
943
+
944
+ assert!(result, "non_empty validation failed for multiline value");
945
+ }
946
+
937
947
  #[test]
938
948
  fn test_unique_key_validation() {
939
949
  let definition_with_non_empty_column = String::from("
File without changes
File without changes