Skip to main content

Unified abstraction for handling xls, xlsx and CSV files in Python

Project description

# TableReader

TableReader is an unified abstraction for handling xls, xlsx and CSV files in Python. It also reads csv tables as unicode on request.

If you are familiar with csv.DictReader from the standard library, think of TableReader as DictReader on steroids.

from tablereader import TableReader

reader = TableReader("some_input.xlsx", sheet="The Data")
for row in reader:
    print row['valuecolumn']

In case you have csv and need unicode support:

reader = TableReader("unicode_input.csv", force_type="unicodecsv")
for row in reader:
    print row['valuecolumn']

If you want to strip out leading and trailing spaces while reading rows, you can:

reader = TableReader("input_with_whitespaces.csv", strip_whitespaces=True)
for row in reader:
    print row['valuecolumn']

And if for some reason you have a file with wrong type by line-ending (commonly found when sharing xls), override auto-detection:

reader = TableReader("wrong_named.xls", force_type="xlsx")
for row in reader:
    print row['valuecolumn']

Sometimes headers are not in the first line. So specify some header row search text and the entire row will be used as column name and all rows after are returned:

from tablereader import OffsetTableReader

reader = OffsetTableReader("wrong_named.xls", "BEGIN_DATA")
for row in reader:
    print row['valuecolumn']

The library has been tested on CPython 2.6, 2.7 and 3.4 as well as PyPy 2.4.1.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tablereader-1.1.1.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

tablereader-1.1.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file tablereader-1.1.1.tar.gz.

File metadata

  • Download URL: tablereader-1.1.1.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for tablereader-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9872a2a05dd6741edbe170aca82016f9036599e5d510e5c5570749b940f7ee53
MD5 b1c14d5cc9e49e4f3ef84921c23d2fc2
BLAKE2b-256 eb2a8437dcc6f0d98071757fe270e293153a3efca6e3a96ba445f9684139ad39

See more details on using hashes here.

File details

Details for the file tablereader-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: tablereader-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for tablereader-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c73c66654582e30e060df92ea40bf3d261175831283e887ad88b051abd59959c
MD5 5af14eb895f81ee8d26fa808656cd830
BLAKE2b-256 0e7989670551eb5466a0a19396601e58fbe27c812ff11ac499f07072aa7ec93d

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