Skip to main content

Excel records' parser and schema viewing and validating tools.

Project description

excelschema

Excel records' parser and schema viewing and validating tools.

Installation

Method 1:

$ pip install excelschema

Method 2:

  • Clone the project from GitHub
  • poetry install

Usage

To read an Excel file, you may also need to install pyexcel and pyexcel-xlsx as well.

>>> from excelschema import SchemaParser
>>> import pyexcel
>>> sp = SchemaParser(records=pyexcel.get_records(file_name='foo.xlsx', sheet_name='bar'))
>>> sp.schema
{
    'record_id': <class 'int'>,
    'modified': <class 'datetime.datetime'>,
    'data': <class 'str'>
}

Validating records and convert it to a usable one.

>>> sp.ensure_one({'record_id': ' 12', 'data': 567})
{'record_id', 12, 'data': '567'}

Setting constraints

>>> from excelschema import Constraint
>>> sp.update_schema({
...     'user_id': Constraint(type_=int, unique=True, not_null=True)
... })

It is also possible to create an custom schema without an Excel

>>> sp = SchemaParser(schema={
...     'record_id': Constraint(type_=int, unique=True, not_null=True),
...     'modified': datetime
... })

Bonus functions

Cleaning dirty Excel records

>>> from excelschema import parse_record
>>> parse_record({'foo': ' 1', 'bar': ' - ', 'baz': ' '})
{'foo', 1}

Related projects

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

excelschema-0.1.2.4.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

excelschema-0.1.2.4-py2.py3-none-any.whl (11.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file excelschema-0.1.2.4.tar.gz.

File metadata

  • Download URL: excelschema-0.1.2.4.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.11.5 CPython/3.7.0 Darwin/17.7.0

File hashes

Hashes for excelschema-0.1.2.4.tar.gz
Algorithm Hash digest
SHA256 252032b935c06dce76064f2928a01a0aaf1c7eb19aade1e5de2ebd297731c2a9
MD5 3b327ce7af70037509bca0c4360daedd
BLAKE2b-256 938284a42191599b7110f44ce7968bb0323bd937a9abb672a791951acd6db4f3

See more details on using hashes here.

File details

Details for the file excelschema-0.1.2.4-py2.py3-none-any.whl.

File metadata

  • Download URL: excelschema-0.1.2.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.11.5 CPython/3.7.0 Darwin/17.7.0

File hashes

Hashes for excelschema-0.1.2.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bac9a183f9fac7666f061229b84e4a48ed8093865c8dee6f0810a54ac7ed7f94
MD5 f98200107cbb36968c463a491ddb0162
BLAKE2b-256 c9477a5dbb47e59c4d8b14b93de2051fad0945bd6fe7191320399eb7b294c3a2

See more details on using hashes here.

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