String Table Parser
sttable is a Python library (version 0.0.1, alpha status) designed to parse string representations of tables, converting them into structured data formats. It extracts table data, making it accessible by rows (as a list of dictionaries) or by columns (as a dictionary of lists). The library currently has an infrequent release cadence, with the last release in November 2019.
Warnings
- gotcha The library is in '3 - Alpha' development status and was last updated in November 2019. This suggests it is not actively maintained, and might have unaddressed bugs or security vulnerabilities. Consider the stability and long-term support before relying on it for critical applications.
- gotcha The parser expects a very specific format for the input string table, including `|` delimiters and `\n` for newlines. Deviations from this strict format may lead to parsing errors or unexpected results.
Install
-
pip install sttable
Imports
- STTable
from sttable import STTable
Quickstart
from sttable import STTable
table_string = (
"header_1st_col | header_2nd_col |\n"
"row_1_of_1st_col | row_1_of_2nd_col |\n"
"row_2_of_1st_col | row_2_of_2nd_col |"
)
table = STTable(table_string)
# Access data by rows
rows_data = table.get_rows()
print("Rows:", rows_data)
# Access data by columns
columns_data = table.get_columns()
print("Columns:", columns_data)
# Access field names
fields = table.get_fields()
print("Fields:", fields)