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, 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',
    },
)

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.1.1

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.1.1
File Size Uploaded
fables-1.1.1.tar.gz 11.5 kB Details

Built distribution (wheel)

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

Total release size: 28.1 kB

Release files / fables-1.1.1.tar.gz

Download URL fables-1.1.1.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
be07965ec880b590730371266ee253d204b2dc513572f357b735f7d92eab2c66
BLAKE2b-256 checksum
How to use checksums
d990eba2346f9b8bd6339ded93c5a8af005bc400583507c30ec903d4a3c5277c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.2

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

Download URL fables-1.1.1-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcdc37e67db7f8fdf95a0ab5f9a26e625c607a369909d1ebd7ec89a202ef1388
BLAKE2b-256 checksum
How to use checksums
21a7dcd3211682eb4a8d62559d170c8044de03c1e5729fbfc19b417eec65120d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.2

Release history Release notifications | RSS feed

1.2.5

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

This release

1.1.1 This release

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