A small and performance-oriented CSV header linter / verifier
Project description
validCSV
A small and performance-oriented CSV header verifier / linter with no external Python package dependencies. Just simple.
1. Usage
CSVheader(validator: dict, default: dict = None, ordered = 0, case = 0):
ordered: set1if the header need to ordered as the same as your validator. SetOotherwise.case: set0if for ignoring the letter case.1otherwise.validator: A dictionary with aheaderkey. Theheadershould be an list that will represent your csv header
1.2. Verifier methods
CSVheader.verify_header(file) # Uses all config combinations (ordered, case) used at instantiation;
CSVheader.simple_verify_header(file,size = None, restrict: bool = True) # Simple leads to only check if the validator elements exists at CSV header; If size is defined, the verifier will check if the header have the length equal to size; restrict will invalidate headers with smaller lengths than your validator;
CSVheader.simple_verify_optional_header(file,size = None, restrict: bool = False, options=[]) # It is similiar to simple_verify_header() but, have set optional header columns. If the header have the same validator elements and at least one optional element, the verifier will return true (passed);
1.3. Example
from validCSV import CSVheader
validHydroNodes = CSVheader(validator={'header': ["id","name","type","block","watersystem","tia","min_alt","max_alt"]})
if validHydroNodes.verify_header(files[filename]):
# Do something
print("Test 1 Passed!")
validQualityStations = CSVheader(validator={'header': ["id","snirh","latitude","longitude"]})
if validQualityStations.simple_verify_header(files[filename]):
# Do something
print("Test 2 Passed!")
validQualityData = CSVheader(validator={'header': ["date"]})
if validQualityData.simple_verify_optional_header(files[filename], options=['id','snirh']):
# Do something
print("Test 3 Passed!")
2. Installation
pip3 install validCSV
2.1 Local installation
git clone https://github.com/bmalbusca/validCSV.gitcd validCSVpython3 setup.py bdist_wheelpip3 install -e .
3. Dependencies
python >= 3.0.0
4. Test
4.1 Setup.py
python3 setup.py sdistcheck-manifest --create
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
validCSV-0.0.1.tar.gz
(4.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file validCSV-0.0.1.tar.gz.
File metadata
- Download URL: validCSV-0.0.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
128f8885171e7897cbb9d2f81bf1f1efa0cbe039f746a5a0f3a1896438a93573
|
|
| MD5 |
975c6a4f3515a66230f67ce21a66536a
|
|
| BLAKE2b-256 |
3cfba344355c29f9695432a6926f89cd7b03fd79c2253dd124f4135223d34324
|
File details
Details for the file validCSV-0.0.1-py3-none-any.whl.
File metadata
- Download URL: validCSV-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
046d33edf74c12104e8448ae739f5ed876cccfe4b3124058d4b5c23c0623ca8d
|
|
| MD5 |
049ffbcc03847048a3cd8c8d9ae18c0b
|
|
| BLAKE2b-256 |
d43e17ea7506955e47b4ce2c6742cbf12c304803b50fcaf1d74d6e506a11e29f
|