pytablereader 0.31.4


pip install pytablereader

  Latest version

Released: Jun 25, 2023


Meta
Author: Tsuyoshi Hombashi
Requires Python: >=3.7

Classifiers

Development Status
  • 4 - Beta

Intended Audience
  • Developers
  • Information Technology

License
  • OSI Approved :: MIT License

Operating System
  • OS Independent

Programming Language
  • Python :: 3
  • Python :: 3.7
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3 :: Only
  • Python :: Implementation :: CPython
  • Python :: Implementation :: PyPy

Topic
  • Database
  • Software Development :: Libraries
  • Software Development :: Libraries :: Python Modules
  • Text Processing

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 CodeQL

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) onetime: Arturi0 onetime: Dmitry Belyaev (b4tman)

Become a sponsor

0.31.4 Jun 25, 2023
0.31.3 Feb 27, 2022
0.31.2 Feb 27, 2022
0.31.1 Oct 17, 2021
0.31.0 Jun 13, 2021
0.30.1 Aug 01, 2020
0.30.0 Apr 15, 2020
0.29.0 Apr 05, 2020
0.28.0 Mar 08, 2020
0.27.2 Feb 14, 2020
0.27.1 Feb 11, 2020
0.27.0 Feb 09, 2020
0.26.5 Jan 13, 2020
0.26.4 Jan 13, 2020
0.26.3 Jan 05, 2020
0.26.2 Jan 05, 2020
0.26.1 May 11, 2019
0.26.0 May 05, 2019
0.25.5 Apr 20, 2019
0.25.4 Apr 13, 2019
0.25.3 Mar 30, 2019
0.25.2 Mar 21, 2019
0.25.1 Mar 16, 2019
0.25.0 Feb 18, 2019
0.24.2 Feb 12, 2019
0.24.1 Jan 27, 2019
0.24.0 Jan 27, 2019
0.23.1 Jan 20, 2019
0.23.0 Jan 13, 2019
0.22.7 Jan 09, 2019
0.22.6 Jan 06, 2019
0.22.5 Jan 03, 2019
0.22.4 Dec 30, 2018
0.22.3 Dec 24, 2018
0.22.2 Nov 25, 2018
0.22.1 Nov 18, 2018
0.22.0 Oct 08, 2018
0.21.1 Oct 07, 2018
0.21.0 Sep 21, 2018
0.20.7 Sep 08, 2018
0.20.6 Aug 05, 2018
0.20.5 Jul 28, 2018
0.20.4 Jul 13, 2018
0.20.3 Jul 13, 2018
0.20.2 Jul 08, 2018
0.20.1 Jun 30, 2018
0.20.0 Jun 17, 2018
0.19.3 Jun 10, 2018
0.19.2 Jun 02, 2018
0.19.1 May 27, 2018
0.19.0 May 13, 2018
0.18.0 May 12, 2018
0.17.1 May 04, 2018
0.17.0 Apr 30, 2018
0.16.1 Apr 29, 2018
0.16.0 Apr 08, 2018
0.15.0 Nov 19, 2017
0.14.0 Nov 19, 2017
0.13.5 Oct 28, 2017
0.13.4 Oct 01, 2017
0.13.3 Aug 19, 2017
0.13.2 Aug 19, 2017
0.13.1 Aug 16, 2017
0.13.0 Aug 09, 2017
0.12.9 Aug 01, 2017
0.12.8 Jul 31, 2017
0.12.7 Jul 29, 2017
0.12.6 Jul 23, 2017
0.12.5 Jul 23, 2017
0.12.4 Jul 22, 2017
0.12.3 Jul 22, 2017
0.12.2 Jul 17, 2017
0.12.1 Jul 16, 2017
0.12.0 Jul 01, 2017
0.11.4 Jun 27, 2017
0.11.3 Jun 25, 2017
0.11.2 May 28, 2017
0.11.1 May 28, 2017
0.11.0 May 27, 2017
0.10.1 May 21, 2017
0.10.0 May 21, 2017
0.9.3 May 14, 2017
0.9.2 May 05, 2017
0.9.1 May 01, 2017
0.9.0 Apr 30, 2017
0.8.11 Apr 23, 2017
0.8.10 Feb 26, 2017
0.8.9 Feb 26, 2017
0.8.8 Jan 08, 2017
0.8.7 Jan 08, 2017
0.8.6 Jan 03, 2017
0.8.5 Jan 01, 2017
0.8.4 Dec 31, 2016
0.8.3 Dec 31, 2016
0.8.2 Dec 30, 2016
0.8.1 Dec 29, 2016
0.8.0 Dec 29, 2016
0.7.2 Dec 25, 2016
0.7.1 Dec 25, 2016
0.7.0 Dec 24, 2016
0.6.8 Dec 10, 2016
0.6.7 Nov 27, 2016
0.6.6 Nov 27, 2016
0.6.5 Nov 23, 2016
0.6.4 Nov 23, 2016
0.6.3 Nov 20, 2016
0.6.1 Nov 15, 2016
0.6.0 Nov 13, 2016
0.5.2 Nov 07, 2016
0.5.1 Nov 07, 2016
0.4.2 Nov 05, 2016
0.4.1 Nov 05, 2016
0.4.0 Nov 03, 2016
0.3.0 Oct 30, 2016
0.2.1 Oct 30, 2016
0.2.0 Oct 29, 2016
0.1.1 Oct 24, 2016
0.1.0 Oct 23, 2016

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
setuptools (>=38.3.0)
beautifulsoup4 (<5,>=4.5.3)
DataProperty (<2,>=0.54.2)
jsonschema (<5,>=2.5.1)
mbstrdecoder (<2,>=1.0.0)
pathvalidate (<4,>=2.5.2)
path (<17,>=13)
tabledata (<2,>=1.1.1)
typepy (<2,>=1.2.0)