A Python library to load structured table data from files/strings/URL with various data format: CSV/Excel/Google-Sheets/HTML/JSON/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/LTSV/Markdown/SQLite/TSV.
Features
- Extract structured tabular data from various data format:
CSV
Microsoft Excel TM file
HTML
JSON
Markdown
MediaWiki
Space separated values (SSV)
SQLite database file
Tab separated values (TSV)
- Supported data sources are:
Files on a local file system
Accessible URLs
str instances
- Loaded table data can be used as:
pandas.DataFrame instance
dict instance
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 http://pytablereader.rtfd.io/en/latest/pages/examples/index.html
Installation
pip install pytablereader
Dependencies
Python 2.7+ or 3.4+
Mandatory Python packages
DataPropery (Used to extract data types)
Optional Python packages
Optional packages (other than Python packages)
libxml2 (faster HTML conversion)
pandoc (required when loading MediaWiki file)
Test dependencies
Documentation
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
Built Distribution
Hashes for pytablereader-0.19.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3112a0b654218cb827fe921d0274c2bb9a4b943e428281dcfe0a8b5033fb7baf |
|
MD5 | 2c2213b85198f4e826d71c8f49e343b6 |
|
BLAKE2b-256 | fdfb1cb54635acd11a88efd47fe344f7574d60d0aba6d96fa0931231d5801164 |