Skip to main content

csvschemavalidation is an implementation of CSV Schema in Python.

Project description

csvschemavalidation

csvschemavalidation is an implementation of CSV Schema in Python.

This project is at Alpha version and still under heavy development.

Example

>>> from csvschemavalidation.checker import Validator
>>> # demo.csv:
... # id,name,value
... # 1,Ann,"5"
... # 2,Ben,"10"
... # 3,Tom,"14"
>>> schema = {
...     'fields': [
...         {
...             'name': 'value',
...             'type': 'number',
...             'multipleOf': 5
...         }
...     ]
... }
>>> v = Validator(csvfile='demo.csv', schema=schema)
>>> v.validate()

Traceback (most recent call last):
...
<ValidationError: 'Value 14.0 is not multiple of 5'; column name: value; row number: 3>

Note that the validator does not check if the CSV format fits the dialect defined in schema correctly. For example, if wrong delimiter present in schema, validator might read the whole line as one cell.

Installation

pip install csvschemavalidation

Requirements

Python 3.5 or above

TODO

  • Documentation and Examples
  • Optional header
  • Decide whether to rely on Python's built-in int and float function to convert values
  • Tests

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

csvschemavalidation-0.0.8.tar.gz (14.0 kB view hashes)

Uploaded Source

Built Distribution

csvschemavalidation-0.0.8-py3-none-any.whl (16.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page