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
Metadata
Release files for excelschema 0.1.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| excelschema-0.1.2.4.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| excelschema-0.1.2.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 16.5 kB
Release files / excelschema-0.1.2.4.tar.gz
| Download URL | excelschema-0.1.2.4.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
252032b935c06dce76064f2928a01a0aaf1c7eb19aade1e5de2ebd297731c2a9
|
|
BLAKE2b-256 checksum How to use checksums |
938284a42191599b7110f44ce7968bb0323bd937a9abb672a791951acd6db4f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.11.5 CPython/3.7.0 Darwin/17.7.0
|
Release files / excelschema-0.1.2.4-py2.py3-none-any.whl
| Download URL | excelschema-0.1.2.4-py2.py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
bac9a183f9fac7666f061229b84e4a48ed8093865c8dee6f0810a54ac7ed7f94
|
|
BLAKE2b-256 checksum How to use checksums |
c9477a5dbb47e59c4d8b14b93de2051fad0945bd6fe7191320399eb7b294c3a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.11.5 CPython/3.7.0 Darwin/17.7.0
|