Skip to main content

Read tables from messy spreadsheets.

Project description

Logo

Travis (.com) Codecov Read the Docs PyPI PyPI - Python Version PyPI - Wheel GitHub last commit PyPI - Downloads

fuzzytable is a set of tools for extracting tabular data out of messy spreadsheets.

This library was developed to meet the needs of projects relying on spreadsheet data that has been handled by many people. Headers are often missing or mispelled. The data is incorrectly formatted. The table is on the wrong worksheet or you don't know the correct spreadsheet name. Etc...

fuzzytable allows you to quickly extract that data instead of arduously QC'ing the data ahead of time. After extraction, you can query the FuzzyTable attributes to e.g. determine which fields were found and how closely the desired header matches the actual header.

Installation

pip install fuzzytable

Example Usage

Here's a light-hearted demo. To read this messy file using, say, the csv module, we'd have to first:

  • Delete rows 1 and 2.
  • Delete columns A and B.
  • Rename the headers.
A B C D E
These are not the droids
you are looking for. He
can go c o l o r first name GivenName
about his Gold C 3PO
business . Blue R2 D2

Let's instead leverage the FuzzyTable class.

>>> from fuzzytable import FuzzyTable

>>> droids = FuzzyTable(
...     path='droids.csv',
...     fields=['first_name', 'last_name', 'color'],
...     approximate_match=True,
...     min_ratio=.3
... )

Now let's play with the data we've extracted.

>>> droids['color']
['Gold', 'Blue']

>>> for droid in droids.records:
...     print(f"{droid['first_name']}-{droid['last_name']} is {droid['color']}.")
C-3PO is Gold.
R2-D2 is Blue.

>>> droids.fields['first_name'].col_num
3

>>> droids.sheet.header_row
2

Links

Supported Formats

  • Excel (.xlsx, .xlsm, .xltx, .xltm)
  • csv (.csv)

Basically, anything that can be read by the openpyxl or csv modules.

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

fuzzytable-0.14a0.tar.gz (326.2 kB view details)

Uploaded Source

Built Distribution

fuzzytable-0.14a0-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

Details for the file fuzzytable-0.14a0.tar.gz.

File metadata

  • Download URL: fuzzytable-0.14a0.tar.gz
  • Upload date:
  • Size: 326.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.22.0

File hashes

Hashes for fuzzytable-0.14a0.tar.gz
Algorithm Hash digest
SHA256 ec5c9a8d0d9b4a0050b2bdea6aa966a24d64c9c3a1cd26cdbe0cf0ba8c34ffa2
MD5 9de3468babc61f70b4b678251edb43b4
BLAKE2b-256 a91de82410a99278c08c18e93a3681dccd9c2fb51dd82c185cbdb89eb62a103b

See more details on using hashes here.

File details

Details for the file fuzzytable-0.14a0-py3-none-any.whl.

File metadata

  • Download URL: fuzzytable-0.14a0-py3-none-any.whl
  • Upload date:
  • Size: 65.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.22.0

File hashes

Hashes for fuzzytable-0.14a0-py3-none-any.whl
Algorithm Hash digest
SHA256 73e012e60c709e37bd53cb18f61bdeb5c510d9cde71fb6e4653a22494d1b8479
MD5 36d36ae3056ec05e570c3f70ff579b5a
BLAKE2b-256 acc21ff02db1119c1729b790c9bd68e21e9ee92430b22713781418be23803fdf

See more details on using hashes here.

Supported by

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