Skip to main content

Build Status Build status

CSV Schema Definition and Validation

Install

pip install csv-schema

Usage

usage: csv-schema [-h] [--version] {validate-config,validate-csv,generate-config} ...

CSV Schema

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

Commands:
  {validate-config,validate-csv,generate-config}
    validate-config     Validates the CSV schema JSON configuration file.
    validate-csv        Validates a CSV file against a schema.
    generate-config     Generate a CSV schema JSON configuration file.

Definition

The CSV file schema definition is defined in a JSON file in the following format.

File Definition:

{
  "name": null,
  "description": null,
  "filename": {
    "regex": null
  },
  "columns": []
}
Property Description
name The name of the schema.
description The description of the schema.
filename Properties for the name of the CSV filename to validate.
columns List of column definitions.

filename

{
  "regex": null
}
Property Description
regex Regular expression to validate the name of the CSV file being validated.

Column Definitions:

string

{
  "type": "string",
  "name": null,
  "required": true,
  "null_or_empty": false,
  "regex": null,
  "min": null,
  "max": null
}
Property Description
type The column type.
name The name of the column.
required Whether or not the column is required in the file.
null_or_empty Whether or not the value can be null (missing) or an empty string.
regex Regular expression to validate the column value.
min The minimum length of the string. null for no limit.
max The maximum length of the string. null for no limit.

integer

{
  "type": "integer",
  "name": null,
  "required": true,
  "null_or_empty": false,
  "regex": null,
  "min": null,
  "max": null
}
Property Description
type The column type.
name The name of the column.
required Whether or not the column is required in the file.
null_or_empty Whether or not the value can be null (missing) or an empty string.
regex Regular expression to validate the column value.
min The minimum value. null for no limit.
max The maximum value. null for no limit.

decimal

{
  "type": "decimal",
  "name": null,
  "required": true,
  "null_or_empty": false,
  "regex": null,
  "min": null,
  "max": null,
  "precision": 2
}
Property Description
type The column type.
name The name of the column.
required Whether or not the column is required in the file.
null_or_empty Whether or not the value can be null (missing) or an empty string.
regex Regular expression to validate the column value.
min The minimum value. null for no limit.
max The maximum value. null for no limit.
precision The decimal point precision.

enum

{
  "type": "enum",
  "name": null,
  "required": true,
  "null_or_empty": false,
  "values": []
}
Property Description
type The column type.
name The name of the column.
required Whether or not the column is required in the file.
null_or_empty Whether or not the value can be null (missing) or an empty string.
values Fixed set of constants.

Development

Setup

pipenv --three
pipenv shell
make pip_install
make build
make install_local

See Makefile for all commands.

Update README Definitions

The schema definition is auto generated by running scripts/generate_md_help.py. Copy/paste the output into the README.md file.

Testing

  • Create and activate a virtual environment:
  • Run the tests: make test

Metadata

Release files for csv-schema 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csv-schema 1.1
File Size Uploaded Provenance Actions
csv-schema-1.1.tar.gz 11.9 kB Without provenance Details for csv-schema-1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for csv-schema 1.1
File Interpreter ABI Platform Actions
csv_schema-1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for csv_schema-1.1-py2.py3-none-any.whl

Total release size: 31.0 kB

Release files / csv-schema-1.1.tar.gz

Download URL csv-schema-1.1.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
551f350b648cc8fc630f6bd27f56bf373960eb9e9c0a6656eb76b56c3d05f6c0
BLAKE2b-256 checksum
How to use checksums
d35923dcb5a51da0693d05f0c68c60026ef6caa6daf1b4ac855ef15f99058036
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0

Release files / csv_schema-1.1-py2.py3-none-any.whl

Download URL csv_schema-1.1-py2.py3-none-any.whl
Size 19.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4ac885c84fce607155e76d309c7e2033a91137a05e0fdf5d481288e698be7e3a
BLAKE2b-256 checksum
How to use checksums
6f09f7595eea9db7bec3634159f5c67eb8c401c71dd1432936b89d2f57aa35cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.0

Security for csv-schema 1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page