Skip to main content

Read in .ods and .fods files and return a pandas.DataFrame.

Project description

pandas-ods-reader

Provides a function to read in a .ods or .fods file and returns a pandas DataFrame.

It uses ezodf to read in .ods files. Since .fods files are essentially xml, lxml is used to read them. The correct parser is automatically chosen based on the file's extension.

If a range is specified in the sheet to be imported, it seems that ezodf imports empty cells as well. Therefore, completely empty rows and columns are dropped from the DataFrame, before it is returned. Only trailing empty rows and columns are dropped.

If the ODS file contains duplicated column names, they will be numbered and the number is appended to the column name in the resulting DataFrame.

Dependencies

  • ezodf
  • lxml
  • pandas

Installation

pip install pandas-ods-reader

Usage

from pandas_ods_reader import read_ods

path = "path/to/file.ods"

# by default the first sheet is imported
df = read_ods(path)

# load a sheet based on its index (1 based)
sheet_idx = 2
df = read_ods(path, sheet_idx)

# load a sheet based on its name
sheet_name = "sheet1"
df = read_ods(path, sheet_name)

# load a file that does not contain a header row
# if no columns are provided, they will be numbered
df = read_ods(path, 1, headers=False)

# load a file and provide custom column names
# if headers is True (the default), the header row will be overwritten
df = read_ods(path, 1, columns=["A", "B", "C"])

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

pandas_ods_reader-1.0.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

pandas_ods_reader-1.0.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file pandas_ods_reader-1.0.1.tar.gz.

File metadata

  • Download URL: pandas_ods_reader-1.0.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.1 Linux/6.6.32_1

File hashes

Hashes for pandas_ods_reader-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e87806d72bba31845de9f0dfa6c5621a5aa9b120cb84049544fee0e8baad8f9c
MD5 c11029c80d7eecf27ea897dbab122400
BLAKE2b-256 fd432574e56daf5d876ebb9c719257dc2459eeaeea4dfa293cdf944eaf2b1faa

See more details on using hashes here.

File details

Details for the file pandas_ods_reader-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pandas_ods_reader-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 35a254ec95665fb654b573d7131787bf177e9126b06746ea3c17b1b972abc79b
MD5 c9100b8d4446a227175dbbf2551d6f8b
BLAKE2b-256 60ffea0aeab80318033bc6717271f17007b76a0216d6aa2c8d95386b4fd36c9f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page