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

Uploaded Source

Built Distribution

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

tablereader-1.0.1.macosx-10.11-intel.tar.gz (8.8 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: tablereader-1.0.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tablereader-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0c92d5ea2334e29112adfa14ae15447cf7bc2ed5e7157a9e25c83c13cac9c053
MD5 46bce69608e57c3a40cc316dba08bbe8
BLAKE2b-256 0b879085cffa5b51bdab10cef68a6d0afb9d02407e28fb9ee255ad7aba61d16a

See more details on using hashes here.

File details

Details for the file tablereader-1.0.1.macosx-10.11-intel.tar.gz.

File metadata

File hashes

Hashes for tablereader-1.0.1.macosx-10.11-intel.tar.gz
Algorithm Hash digest
SHA256 4aeb069125c9540521854bfd684c848762e6c776f43d65ce91cd0282091a3b2c
MD5 853885921d22a86b55d64741a7af65c8
BLAKE2b-256 29fabf880d58a6df2ad6bc7e20807f14926283a64de7db8899be9d3db005008f

See more details on using hashes here.

Supported by

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