csv-validation 0.1.1__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.
- {csv_validation-0.1.1 → csv_validation-0.1.2}/Cargo.lock +1 -1
- {csv_validation-0.1.1 → csv_validation-0.1.2}/Cargo.toml +1 -1
- {csv_validation-0.1.1 → csv_validation-0.1.2}/PKG-INFO +16 -16
- {csv_validation-0.1.1 → csv_validation-0.1.2}/README.md +15 -15
- {csv_validation-0.1.1 → csv_validation-0.1.2}/src/lib.rs +22 -1
- {csv_validation-0.1.1 → csv_validation-0.1.2}/.github/workflows/CI.yml +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/.gitignore +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/LICENSE +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/MANIFEST.in +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/build.sh +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/csv_validation.pyi +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/pyproject.toml +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/test/duplicated_unique_keys.csv +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/test/empty_values.csv +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/test/test_file.csv +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/test/test_file.csv.gz +0 -0
- {csv_validation-0.1.1 → csv_validation-0.1.2}/test/test_validations.yml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: csv_validation
|
|
3
|
-
Version: 0.1.
|
|
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: "
|
|
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):
|
|
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
|
|
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
|
-
✔ -
|
|
259
|
+
✔ - regex: '^.*$'
|
|
260
260
|
- City: [✔] OK
|
|
261
|
-
✔ -
|
|
261
|
+
✔ - regex: '^.*$'
|
|
262
262
|
- Model Year: [✔] OK
|
|
263
|
-
✔ -
|
|
264
|
-
✔ -
|
|
265
|
-
✔ -
|
|
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
|
-
✖ -
|
|
271
|
-
"Wrong Rows: 93 | Sample: 'GA','NJ','CT','NJ','CT'
|
|
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
|
-
✔ -
|
|
274
|
-
✖ -
|
|
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: "
|
|
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):
|
|
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
|
|
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
|
-
✔ -
|
|
247
|
+
✔ - regex: '^.*$'
|
|
248
248
|
- City: [✔] OK
|
|
249
|
-
✔ -
|
|
249
|
+
✔ - regex: '^.*$'
|
|
250
250
|
- Model Year: [✔] OK
|
|
251
|
-
✔ -
|
|
252
|
-
✔ -
|
|
253
|
-
✔ -
|
|
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
|
-
✖ -
|
|
259
|
-
"Wrong Rows: 93 | Sample: 'GA','NJ','CT','NJ','CT'
|
|
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
|
-
✔ -
|
|
262
|
-
✖ -
|
|
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
|
|
@@ -336,7 +336,7 @@ fn validation_for_non_empty() -> Validation {
|
|
|
336
336
|
}
|
|
337
337
|
|
|
338
338
|
fn regex_for_non_empty() -> String {
|
|
339
|
-
String::from("^.+$")
|
|
339
|
+
String::from("(?s)^.+$")
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
fn validate_column_names(reader: &mut Reader<Box<dyn Read>>, validations: &Vec<ColumnValidations>) -> PyResult<bool> {
|
|
@@ -923,6 +923,27 @@ mod tests {
|
|
|
923
923
|
assert!(!validator.validate("test/empty_values.csv").unwrap());
|
|
924
924
|
}
|
|
925
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
|
+
|
|
926
947
|
#[test]
|
|
927
948
|
fn test_unique_key_validation() {
|
|
928
949
|
let definition_with_non_empty_column = String::from("
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|