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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
252032b935c06dce76064f2928a01a0aaf1c7eb19aade1e5de2ebd297731c2a9
|
|
| MD5 |
3b327ce7af70037509bca0c4360daedd
|
|
| BLAKE2b-256 |
938284a42191599b7110f44ce7968bb0323bd937a9abb672a791951acd6db4f3
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bac9a183f9fac7666f061229b84e4a48ed8093865c8dee6f0810a54ac7ed7f94
|
|
| MD5 |
f98200107cbb36968c463a491ddb0162
|
|
| BLAKE2b-256 |
c9477a5dbb47e59c4d8b14b93de2051fad0945bd6fe7191320399eb7b294c3a2
|