Read ODS files into a pandas DataFrame while preserving direct formatting (bold, italic, underline, superscript, subscript, and anchors) as markup (AsciiDoc, Markdown, HTML).
Project description
direct-formatting-pandas-ods-reader
Inspired from pandas-ods-reader, but with the ability to read direct formatting. pandas-ods-reader relies on ezodf to extract cell content, but ezodf ignores direct formatting, so we need to go at a lower level.
The direct (italic, bold, underline, subscript, superscript, and anchors) formatting is turned into markup in the resulting pandas DataFrame.
Dependencies
lxmlpandas
Usage
In a Python project
from direct_formatting_pandas_ods_reader import read_ods
# single global format
df = read_ods("test/test.ods")
df = read_ods("test/test.ods", format="markdown")
df = read_ods("test/test.ods", format="html", sheet=0)
# or per-column formats:
df = read_ods("test/test.ods", format={
"Column 1": "markdown",
"Column 3": "html"
})
The format argument can be:
"html","markdown","asciidoc"or"none"(global format for all columns),- or a dict mapping column labels to formats (unspecified column labels to
"none")
sheet_index defaults to 0, which corresponds to the first sheet of the file.
Command-line usage
You can use this package as a CLI tool:
python -m direct_formatting_pandas_ods_reader input.ods -o output.csv -t html
input.odspath to the ODS file (required).-o,--outputoutput CSV file (if omitted, writes to standard output).-t,--typeoutput format for formatting marks (asciidoc, markdown, html). Defaults to asciidoc.-s,--sheetindex of the sheet to read (0-based, default: 0).
Install as a global CLI tool
pip install -e .
This creates a global direct-formatting-ods-to-csv command:
direct-formatting-ods-to-csv input.ods -t markdown
License
Licensed under the GNU GPL v3.0, Yann Trividic.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file direct_formatting_pandas_ods_reader-0.5.0.tar.gz.
File metadata
- Download URL: direct_formatting_pandas_ods_reader-0.5.0.tar.gz
- Upload date:
- Size: 46.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c0051f0f6c7b8455d85640d92202899c5acc036bd15586cebda64c73a03ef52
|
|
| MD5 |
cb411628b29076cc3462ec0512e94c14
|
|
| BLAKE2b-256 |
0dcc59628c3bb91a8897026cfd0feeacfc6f3a7d06941a376e4f1e330808474a
|
File details
Details for the file direct_formatting_pandas_ods_reader-0.5.0-py3-none-any.whl.
File metadata
- Download URL: direct_formatting_pandas_ods_reader-0.5.0-py3-none-any.whl
- Upload date:
- Size: 33.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
243e53c7ac8f3cc0a80c451b5ba06009e4a7c004e0b1f0aac6ef1afb7effcc1a
|
|
| MD5 |
d24b43643be610361e576626f2885293
|
|
| BLAKE2b-256 |
9745b8640ec01b8fd63c6c2648fff5b2e2f97c3ad71cb7c235e0d3c8a5672701
|