pyexcel-ezodf: OpenDocumentFormat files

0.3.4 · active · verified Fri Apr 17

pyexcel-ezodf is a Python package that serves as a pyexcel plugin, enabling it to read from and write to OpenDocumentFormat (ODF) files, commonly used by LibreOffice or OpenOffice. It provides an easy way to manipulate tabular data within ODS documents through the familiar pyexcel API. The current version is 0.3.4, with releases typically being maintenance updates rather than frequent feature additions.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `pyexcel-ezodf` as a `pyexcel` plugin to save Python data to an ODS file and then read it back. No explicit import from `pyexcel_ezodf` is needed for `pyexcel` to recognize and handle ODS files; simply installing the plugin is enough.

import pyexcel
import os

# Data to write to an ODS file
data = [
    ["Item", "Quantity", "Price"],
    ["Apple", 10, 1.5],
    ["Banana", 5, 0.75],
    ["Orange", 8, 1.2]
]

# Define a temporary file name
file_name = "example.ods"

try:
    # Save the data to an ODS file
    pyexcel.save_as(array=data, dest_file_name=file_name)
    print(f"'{file_name}' created successfully.")

    # Read data from the ODS file
    sheet = pyexcel.get_sheet(file_name=file_name)
    print("\nRead data from ODS file:")
    for row in sheet:
        print(row)

    # You can also get a dictionary or other formats
    book_dict = pyexcel.get_book_dict(file_name=file_name)
    print("\nBook dictionary:", book_dict)

finally:
    # Clean up the created file
    if os.path.exists(file_name):
        os.remove(file_name)
        print(f"Cleaned up '{file_name}'.")

view raw JSON →