Skip to main content

pytablereader is a python library to load structured table data from various data format: CSV/HTML/JSON/MediaWiki/Excel.

Project description

pytablereader

https://img.shields.io/pypi/pyversions/pytablereader.svg https://travis-ci.org/thombashi/pytablereader.svg?branch=master https://coveralls.io/repos/github/thombashi/pytablereader/badge.svg?branch=master

Summary

pytablereader is a python library to load structured table data from various data format: CSV/HTML/JSON/MediaWiki/Excel.

Feature

  • Extract structured table data from various data format:
    • CSV file/text

    • HTML file/text

    • JSON file/text

    • MediaWiki file/text

    • Microsoft Excel TM file

Examples

Load a CSV table

from __future__ import print_function
import pytablereader

file_path = "sample_data.csv"
data = "\n".join([
    '"attr_a","attr_b","attr_c"',
    '1,4,"a"',
    '2,2.1,"bb"',
    '3,120.9,"ccc"',
])

with open(file_path, "w") as f:
    f.write(data)

# load from a csv file ---
loader = pytablereader.CsvTableFileLoader(file_path)
for table_data in loader.load():
    print("load from file: {:s}".format(table_data))

# load from a csv text ---
loader = pytablereader.CsvTableTextLoader(csv_text)
for table_data in loader.load():
    print("load from text: {:s}".format(table_data))
load from file: table_name=sample_data, header_list=[u'attr_a', u'attr_b', u'attr_c'] record_list=[['1', '4', u'a'], ['2', '2.1', u'bb'], ['3', '120.9', u'ccc']]
load from text: table_name=csv2, header_list=[u'attr_a', u'attr_b', u'attr_c'] record_list=[['1', '4', u'a'], ['2', '2.1', u'bb'], ['3', '120.9', u'ccc']]

For more information

More examples are available at http://pytablereader.readthedocs.org/en/latest/pages/examples/index.html

Installation

pip install pytablereader

Dependencies

Python 2.7+ or 3.3+

Mandatory Python packages

Optional (not Python packages)

  • lxml (faster HTML convert if installed)

  • pandoc (require when loading MediaWiki)

Test dependencies

Documentation

http://pytablereader.readthedocs.org/en/latest/

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pytablereader-0.1.0.tar.gz (18.8 kB view hashes)

Uploaded Source

Built Distribution

pytablereader-0.1.0-py2.py3-none-any.whl (21.6 kB view hashes)

Uploaded Python 2 Python 3

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