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

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.2.tar.gz (53.8 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.2-py2.py3-none-any.whl (32.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for pytablereader-0.5.2.tar.gz
Algorithm Hash digest
SHA256 fa7370bfdae22acc7c01a22696196eef9412088a284c289667acb20351554095
MD5 0fc24b85a5128facf2c5e0cc9dc4b5ad
BLAKE2b-256 c358f7f731d63cfa5133c9bc023a8abcb438a8900905d42675cdefb87a195839

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytablereader-0.5.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f44fea8232b93de55dbaa227461189e2960502c66691e444086144a465292551
MD5 7530ed1521650f618848c1e633dd3ff5
BLAKE2b-256 ca5fef3393eeb1cf053d411126271981fb6f471093c327a8f8d582585c0f98a8

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