Skip to main content

(F)ile T(ables)

Project description

Fables - (F)ile T(ables)

CircleCI Apache2.0License Checked with mypy Code style: black

For users:

Parse the tabular data in the input file:

import fables

for parse_result in fables.parse('myfile.zip'):
    for table in parse_result.tables:
        print(table.name)
        print(table.df.head())
    for error in parse_result.errors:
        print(error.message)

Inspect the contents of the input file:

node = fables.detect('myfile.zip')
print(node.name)
print(node.mimetype)

for child in node.children:
    print(child.name)
    print(child.mimetype)

Note if you've already discovered the input tree from detect(), you can pass it into parse():

parse_results = parse(tree=node)

Handling encrypted zip, xlsx, xlsb, and xls files:

node = fables.detect('encrypted.xlsx')
assert node.encrypted
node.add_password('encrypted.xlsx', 'fables')
assert not node.encrypted

You can also supply a passwords dictionary (filename -> password) into detect and parse:

node = fables.detect(
    'encrypted.zip',
    passwords={
        'encrypted.zip': 'fables',
        # an encrypted file inside the zip
        'encrypted.xlsx': 'foobles',
    }
)
# and/or parse
parse_results = fables.parse(
    'sub_dir',
    passwords={
        'sub_dir/encrypted.xlsx': 'fables',
        'sub_dir/encrypted.xls': 'foobles',
    },
)

Seeing is believing:

Clone the repository & run the example file by executing the example.py script with the following command:

python3 example.py

Installation

The python library python-magic requires additional system dependencies. There are installation instructions there, but here are recommended routes to try:

  • on OSX: brew install libmagic.

  • on Windows: this pip install python-magic-bin will install a built version using ctypes to access the libmagic file type identification library.

Then pip install -r requirements.txt should do the trick.

For contributors:

Tests

  • all tests: pytest
    • coverage: pytest --cov=fables tests
  • integration: pytest tests/integration
    • coverage: pytest --cov=fables tests/integration
  • unit: pytest tests/unit
    • coverage: pytest --cov=fables tests/unit

Note all the coverage statistics are for statements.

Type checking with mypy

  • mypy fables

Linting

  • We enforce flake8:
    • flake8 .

Run test, type checking, and linter all at once

  • nox

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

fables-1.2.4.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

fables-1.2.4-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file fables-1.2.4.tar.gz.

File metadata

  • Download URL: fables-1.2.4.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.5

File hashes

Hashes for fables-1.2.4.tar.gz
Algorithm Hash digest
SHA256 58efbd6e76e2940f5d9e2d4e4c9921f5f195c8e2724ef779fd2173d51abc055e
MD5 eb2bf2d657daf1f5983324179a6f87d2
BLAKE2b-256 07b572ff0b20adb5c75bc5c0fa7fccc5d3b7c1bc91be1cc284f190d3933436bb

See more details on using hashes here.

File details

Details for the file fables-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: fables-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.7.5

File hashes

Hashes for fables-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c83be04c5e9eeded73e98712b24fc9bfa33ee3a7b17a9e64caac7756881a0b7f
MD5 2e27fed0b3dc5ce246818f5bfdc0fced
BLAKE2b-256 d788dfb65d8196bd7e72dae1215c9c89e248f20172b50b74c58f95fb7e2ff056

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