Registry / data / pycsvschema

pycsvschema

JSON →
library0.0.6pypypiunverified

PyCSVSchema is a Python implementation of the CSV Schema specification (version 0.3). It allows you to validate CSV files against a schema defined in YAML or JSON. Currently at version 0.0.6, it is in early development with weekly commits.

pip install pycsvschema
INSTALL
IMPORT
SIG · PYCSVSCHEMA
P
pycsvschema
datapythonv0.0.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CSVSchema
✓ from pycsvschema import CSVSchema
✗ from pycsvschema import CSVSchema

Load a schema from YAML, create a CSVSchema instance, and validate a CSV file.

import yaml from pycsvschema import CSVSchema schema_yaml = """ fields: - name: id type: integer constraints: required: true - name: name type: string """ schema = yaml.safe_load(schema_yaml) validator = CSVSchema(schema) with open('data.csv', 'r') as f: errors = validator.validate(f) for error in errors: print(error)
csvschema --version
Debug
Known issues
gotchaPyCSVSchema expects the schema in Python dict form (parsed from YAML/JSON), not a raw string. Passing a schema string directly will raise a TypeError.
fix
Parse the schema using yaml.safe_load() or json.loads() before passing to CSVSchema.
affects: all
breakingIn v0.0.6, the library switched from CSVValidator class to CSVSchema. Importing CSVValidator from pycsvschema no longer works.
fix
Use CSVSchema instead of CSVValidator. Change imports and constructor calls.
affects: >=0.0.6
deprecatedUsing 'validate()' with a file path string is deprecated; always pass a file object (opened via open()).
fix
Use with open('file.csv') as f: validator.validate(f) instead of validator.validate('file.csv').
affects: >=0.0.5
Upgrade
Version history
0.0.6latest on PyPI · released Oct 9, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
Resources
pycsvschema — pip install pycsvschema · libregistry