Skip to main content

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

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.5.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fables-1.2.5.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.5.tar.gz
Algorithm Hash digest
SHA256 682c42563158c1d824d0ee2b7c2d69c4a8c99723349bf35f074ec10f7d8577d0
MD5 09d7b8bd6f4fa7a94a1937cfb992bb2c
BLAKE2b-256 7a8cdb525071e2113274a44d0cc1c377c2d0c36c79a20de1f182258d556d8932

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fables-1.2.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0d30b0ef926016b633cb7193557df9b88dc9946f54823906019bbc95f5468e4a
MD5 e63fbfedcda88d3015511890bdf4c26b
BLAKE2b-256 93cf76b9b8c71f4c3705f370b3ef733c3a9fe57b4c8897fca6c9337a0b86f5e2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.5 This release

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.0

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page