Skip to main content

Read ODS files into a pandas DataFrame while preserving direct formatting (strong, emphasis, underline, superscript, subscript, and anchors) as markup (AsciiDoc, Markdown, HTML).

Project description

direct-formatting-pandas-ods-reader

pipeline status

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 (emphasis, strong, underline, subscript, superscript, and anchors) formatting is turned into markup in the resulting pandas DataFrame.

Dependencies

  • lxml
  • pandas

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:

  1. "html", "markdown", "asciidoc" or "none" (global format for all columns),
  2. 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.ods path to the ODS file (required).
  • -o, --output output CSV file (if omitted, writes to standard output).
  • -t, --type output format for formatting marks (asciidoc, markdown, html). Defaults to asciidoc.
  • -s, --sheet index 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

direct_formatting_pandas_ods_reader-0.5.1.tar.gz (46.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file direct_formatting_pandas_ods_reader-0.5.1.tar.gz.

File metadata

File hashes

Hashes for direct_formatting_pandas_ods_reader-0.5.1.tar.gz
Algorithm Hash digest
SHA256 5e46020d4a2930d077c143e386973e900debfacdab86976d1fa32143d8a05da8
MD5 145dd24f0350334d4cd949e4475089ad
BLAKE2b-256 013b82e2dfb2e64c31bc3270e33ddcdd6133fc5b4197f9f9eed5e2e0fae53c61

See more details on using hashes here.

File details

Details for the file direct_formatting_pandas_ods_reader-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for direct_formatting_pandas_ods_reader-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dfcd40f80dfe8b251ebdc0aea0fc9d84fdf4d4e097cb1bfaf732e8e4d7517a99
MD5 e47d94564b7511e032d137a22af836a8
BLAKE2b-256 2b845867935e7c6c137de487d905f664122f6634b27854f909935ac4b8307dc7

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