Skip to main content

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

Project description

pytablereader

https://img.shields.io/pypi/pyversions/pytablereader.svg Linux CI test status Windows CI test status 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/Excel/HTML/JSON/Markdown/MediaWiki/MediaWiki.

Feature

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

    • Microsoft Excel TM file

    • HTML file/text

    • JSON file/text

    • Markdown file/text

    • MediaWiki file/text

  • Supported data sources to read:
    • Local file

    • URL

Examples

Load a CSV table

from __future__ import print_function
import pytablereader

# prepare data ---
file_path = "sample_data.csv"
csv_text = "\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(csv_text)

# load from a csv file ---
loader = pytablereader.CsvTableFileLoader(file_path)
for table_data in loader.load():
    print("\n".join([
        "load from file",
        "==============",
        "{:s}".format(table_data.dumps()),
    ]))

# load from a csv text ---
loader = pytablereader.CsvTableTextLoader(csv_text)
for table_data in loader.load():
    print("\n".join([
        "load from text",
        "==============",
        "{:s}".format(table_data.dumps()),
    ]))
load from file
==============
.. table:: sample_data

    ======  ======  ======
    attr_a  attr_b  attr_c
    ======  ======  ======
         1     4.0  a
         2     2.1  bb
         3   120.9  ccc
    ======  ======  ======

load from text
==============
.. table:: csv2

    ======  ======  ======
    attr_a  attr_b  attr_c
    ======  ======  ======
         1     4.0  a
         2     2.1  bb
         3   120.9  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 Python packages

  • pypandoc
    • required when loading MediaWiki file

  • pandas
    • required to get table data as a pandas data frame

Optional packages (other than Python packages)

  • lxml (faster HTML convert if installed)

  • pandoc (required when loading MediaWiki file)

Test dependencies

Documentation

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

Project details


Release history Release notifications | RSS feed

This version

0.5.1

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

Uploaded Source

Built Distribution

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

pytablereader-0.5.1-py2.py3-none-any.whl (32.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pytablereader-0.5.1.tar.gz.

File metadata

  • Download URL: pytablereader-0.5.1.tar.gz
  • Upload date:
  • Size: 40.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytablereader-0.5.1.tar.gz
Algorithm Hash digest
SHA256 da698336387552625465a9dd8b5ae1bbc2bbb9d6c9d43cd3a08d6b527e26a342
MD5 177c428bc368defb4a83eb471da42204
BLAKE2b-256 6e12b342f4da31c28bc3e2ddf30a98ae80b851c3237cf55c25e39debc9757178

See more details on using hashes here.

File details

Details for the file pytablereader-0.5.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytablereader-0.5.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 48a49a8404d510975be5eee4065095391d1fa3b78a746e7f1279b64d251d5199
MD5 6fc8bd3a2edb273361d1c2e8fa2d8a43
BLAKE2b-256 e63d160c929114d7739a5cafa97f5da3ae22264a845cfd47d6e8c5d2dc9ed7bc

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