Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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.

Files for excelschema, version 0.1.2.4
Filename, size File type Python version Upload date Hashes
Filename, size excelschema-0.1.2.4-py2.py3-none-any.whl (11.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size excelschema-0.1.2.4.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page