Metadata-Version: 2.1
Name: tablereader
Version: 1.1.1
Summary: Unified abstraction for handling xls, xlsx and CSV files in Python
Home-page: https://github.com/jokey2k/tablereader
Author: Markus Ullmann
Author-email: mail@markus-ullmann.de
License: BSD-3
Keywords: encoding,csv,xlsx,xls,xlsm,unicode
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Plugins
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Internet :: Log Analysis
Classifier: Topic :: Office/Business :: Financial :: Spreadsheet
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Software Development :: User Interfaces
Classifier: Topic :: Text Editors :: Text Processing
Classifier: Topic :: Text Processing :: Filters
Classifier: Topic :: Utilities
License-File: LICENSE

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

.. code-block:: python

    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:

.. code-block:: python

    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:

.. code-block:: python

    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:

.. code-block:: python

    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:

.. code-block:: python

    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.

