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

Release files for fables 1.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fables 1.2.5
File Size Uploaded
fables-1.2.5.tar.gz 16.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fables 1.2.5
File Interpreter ABI Platform
fables-1.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 33.9 kB

Release files / fables-1.2.5.tar.gz

Download URL fables-1.2.5.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
682c42563158c1d824d0ee2b7c2d69c4a8c99723349bf35f074ec10f7d8577d0
BLAKE2b-256 checksum
How to use checksums
7a8cdb525071e2113274a44d0cc1c377c2d0c36c79a20de1f182258d556d8932
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / fables-1.2.5-py3-none-any.whl

Download URL fables-1.2.5-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d30b0ef926016b633cb7193557df9b88dc9946f54823906019bbc95f5468e4a
BLAKE2b-256 checksum
How to use checksums
93cf76b9b8c71f4c3705f370b3ef733c3a9fe57b4c8897fca6c9337a0b86f5e2
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.2.5 This release

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page