Skip to main content

Generate a json file from an OpenDocument Format .ods file

Project description

odsparsator, a .ods parser.

Generate a JSON file from an OpenDocument Format .ods file.

When used as a script, odsparsator parses a .ods file and generates a JSON file using the odfdo library.

When used as a library, odsparsator parses a .ods file and returns a Python structure.

The resulting data follows the format of the reverse odsgenerator.py script, see https://github.com/jdum/odsgenerator

odsparsator is a Python3 package, using the odfdo library. Current version requires Python >= 3.9, see prior versions for older environments.

Project: https://github.com/jdum/odsparsator

Author: jerome.dumonteil@gmail.com

License: MIT

Installation

Installation from Pypi (recommended):

pip install odsparsator

Installation from sources (requiring setuptools):

pip install .

CLI usage

odsparsator [-h] [--version] [options] input_file output_file

arguments

input_file: input file, a .ods file.

output_file: output file, JSON file generated from input.

Use odsparsator --help for options:

options:
  -h, --help         show this help message and exit
  --version          show program's version number and exit
  -m, --minimal      keep only rows and cells, no styles, no formula, no column width
  -a, --all-styles   collect all styles from the input
  -c, --color        collect background color of cells
  -k, --keep-styled  keep styled cells with empty value
  -s, --see-hidden   parse also the hidden sheets

sample


$ odsparsator --minimal sample.ods sample_minimal.json

The result:

{
    "body": [
        {
            "name": "first tab",
            "table": [
                ["a", "b", "c"],
                [10, 20, 30]
            ]
        }
    ]
}

Without the --minimal option:

$ odsparsator sample.ods sample_with_styles.json

The result:

{
"body": [
    {
        "name": "first tab",
        "table": [
            {
                "row": [
                    {
                        "value": "a",
                        "style": "bold_center_bg_gray_grid_06pt"
                    },
                    {
                        "value": "b",
                        "style": "bold_center_bg_gray_grid_06pt"
                        ...

Usage from python code

from odsparsator import odsparsator

content = odsparsator.ods_to_python("sample1.ods")

Documentation

See in the ./doc folder:

html/odsparsator.html

License

This project is licensed under the MIT License (see the LICENSE file for details).

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

odsparsator-1.12.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

odsparsator-1.12.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file odsparsator-1.12.1.tar.gz.

File metadata

  • Download URL: odsparsator-1.12.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.19

File hashes

Hashes for odsparsator-1.12.1.tar.gz
Algorithm Hash digest
SHA256 6e4dac267711e332dd4eaf21e4645ad96bcae6370adb180730f41ca764070279
MD5 75e7f33237b3df7350382db12c4db8da
BLAKE2b-256 06012e4a86a793c55a6260d892473b25a726972d6b1b0361602ff48eafb17b78

See more details on using hashes here.

File details

Details for the file odsparsator-1.12.1-py3-none-any.whl.

File metadata

File hashes

Hashes for odsparsator-1.12.1-py3-none-any.whl
Algorithm Hash digest
SHA256 816c2f03383644cc4b8328c34716a09c8209eba9b63c9a7a9774ea4beea04028
MD5 1ab5fe122f03597956488a3be36b2fe1
BLAKE2b-256 648a712f0b270bc43c9add68fa193cc18d8632fa1eec86a37a8b1dca66b105d0

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