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': Constraint(type_=int, unique=False, not_null=False),
'modified': Constraint(type_=datetime.datetime, unique=False, not_null=False)
}
Validating records and convert it to a usable one.
>>> sp.ensure_one({'foo': ' 1', 'bar': '-'})
{'foo', 1}
Setting constraints
>>> from tinydb_constraint 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
... })
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
excelschema-0.1.0.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for excelschema-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82785f1c0a589e6eb7ccd7f155aad108ef59379ab55c01edf9c13331299362a5 |
|
MD5 | 69ad57a8996119aef2457c81e8b10caf |
|
BLAKE2b-256 | d75f48a780ae2f972cd04a2f979678ca444c11340f51eb6164e4d760ce01f2e4 |