Skip to main content

A Python library to load structured table data from files/strings/URL with various data format: CSV / Excel / Google-Sheets / HTML / JSON / LDJSON / LTSV / Markdown / SQLite / TSV.

Project description

pytablereader

Summary

A Python library to load structured table data from files/strings/URL with various data format: CSV / Excel / Google-Sheets / HTML / JSON / LDJSON / LTSV / Markdown / SQLite / TSV.

https://badge.fury.io/py/pytablereader.svg 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 https://img.shields.io/github/stars/thombashi/pytablereader.svg?style=social&label=Star

Features

Examples

Load a CSV table

Sample Code:
import pytablereader as ptr
import pytablewriter as ptw


# 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 = ptr.CsvTableFileLoader(file_path)
for table_data in loader.load():
    print("\n".join([
        "load from file",
        "==============",
        "{:s}".format(ptw.dump_tabledata(table_data)),
    ]))

# load from a csv text ---
loader = ptr.CsvTableTextLoader(csv_text)
for table_data in loader.load():
    print("\n".join([
        "load from text",
        "==============",
        "{:s}".format(ptw.dump_tabledata(table_data)),
    ]))
Output:
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
    ======  ======  ======

Get loaded table data as pandas.DataFrame instance

Sample Code:
import pytablereader as ptr

loader = ptr.CsvTableTextLoader(
    "\n".join([
        "a,b",
        "1,2",
        "3.3,4.4",
    ]))
for table_data in loader.load():
    print(table_data.as_dataframe())
Output:
     a    b
0    1    2
1  3.3  4.4

For more information

More examples are available at https://pytablereader.rtfd.io/en/latest/pages/examples/index.html

Installation

pip install pytablereader

Dependencies

Python 2.7+ or 3.4+

Mandatory Python packages

Optional Python packages

Optional packages (other than Python packages)

  • libxml2 (faster HTML conversion)

  • pandoc (required when loading MediaWiki file)

Test dependencies

Documentation

https://pytablereader.rtfd.io/

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.21.1.tar.gz (66.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.21.1-py2.py3-none-any.whl (45.6 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: pytablereader-0.21.1.tar.gz
  • Upload date:
  • Size: 66.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for pytablereader-0.21.1.tar.gz
Algorithm Hash digest
SHA256 d4861ce942ab4ff4160cf86d9ed02f3e75294f194566f012edf77f9798598918
MD5 5af5e76d616d05dfe1c600cd4a61de87
BLAKE2b-256 cc0cf4c352bb22d5c903ab5326baafef953b4b2ae73e2f0fde98fbabc62a84b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytablereader-0.21.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 45.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for pytablereader-0.21.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8894075e92ddf731a1c29aa33e22f3f53300cf2d48fae6d82f3b5d9bf10806e3
MD5 7e1efa2d34c9f46c924defb700ee79f9
BLAKE2b-256 93e762233bafcfd5363028c3f2f1fa4dba270afb654c2a746b2eec17bcada806

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