Skip to main content

pytablereader is 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

Summary

pytablereader is 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.

PyPI package version Supported Python versions Supported Python implementations CI status of Linux/macOS/Windows Test coverage GitHub stars

Features

  • Extract structured tabular data from various data format:
  • Supported data sources are:
    • Files on a local file system

    • Accessible URLs

    • str instances

  • Loaded table data can be used as:

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

Install from PyPI

pip install pytablereader

Some of the formats require additional dependency packages, you can install the dependency packages as follows:

  • Excel
    • pip install pytablereader[excel]

  • Google Sheets
    • pip install pytablereader[gs]

  • Markdown
    • pip install pytablereader[md]

  • Mediawiki
    • pip install pytablereader[mediawiki]

  • SQLite
    • pip install pytablereader[sqlite]

  • Load from URLs
    • pip install pytablereader[url]

  • All of the extra dependencies
    • pip install pytablereader[all]

Install from PPA (for Ubuntu)

sudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install python3-pytablereader

Dependencies

Optional Python packages

Optional packages (other than Python packages)

  • libxml2 (faster HTML conversion)

  • pandoc (required when loading MediaWiki file)

Documentation

https://pytablereader.rtfd.io/

Sponsors

Charles Becker (chasbecker)

Become a sponsor

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.31.0.tar.gz (71.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.31.0-py3-none-any.whl (48.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytablereader-0.31.0.tar.gz
  • Upload date:
  • Size: 71.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

File hashes

Hashes for pytablereader-0.31.0.tar.gz
Algorithm Hash digest
SHA256 9977677c19883e29f7e2cd6c0eda588ce1fbde6d73632f64d670a531bc4a9cf7
MD5 00570f3e8f9d3f253f372cac24dcdd69
BLAKE2b-256 5270672ed4cdbd8a2c8489e8b4d2f5a3fd8f31fc5a75fa9ea5f83195b0d7e859

See more details on using hashes here.

File details

Details for the file pytablereader-0.31.0-py3-none-any.whl.

File metadata

  • Download URL: pytablereader-0.31.0-py3-none-any.whl
  • Upload date:
  • Size: 48.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.5

File hashes

Hashes for pytablereader-0.31.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f99d439ee0a97281bd081bcf0c3bdf18123fe1b6ced438e9fbb052b73ece723
MD5 d594d94d8b38744fbd80267932742d45
BLAKE2b-256 601e59cf5016b220e36e38ca05126e27c99f93496660f9ad47bc7bba8fe00d78

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