odsgenerator


Nameodsgenerator JSON
Version 1.9.0 PyPI version JSON
download
home_pagehttps://github.com/jdum/odsgenerator
SummaryGenerate an OpenDocument Format .ods file from json or yaml file
upload_time2024-01-28 14:16:07
maintainer
docs_urlNone
authorJérôme Dumonteil
requires_python>=3.9,<4
licenseMIT
keywords opendocument odf ods json spreadsheet generator
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # odsgenerator, a .ods generator.

Generate an OpenDocument Format `.ods` file from a `.json` or `.yaml` file.


When used as a script, `odsgenerator` parses a JSON or YAML description of
tables and generates an ODF document using the `odfdo` library.

When used as a library, `odsgenerator` parses a Python description of tables
and returns the ODF content as bytes (ready to be saved as a valid ODF document).

-  The content description can be minimalist: a list of lists of lists,
-  or description can be complex, allowing styles at row or cell level.

See also https://github.com/jdum/odsparsator which is doing the reverse
operation, `.osd` to `.json`.

`odsgenerator` is a `Python3` package, using the [odfdo](https://github.com/jdum/odfdo) library. Current version requires Python >= 3.9, see prior versions for older environments.

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

Author:
    jerome.dumonteil@gmail.com

License:
    MIT


## Installation

Installation from Pypi (recommended):

```python
pip install odsgenerator
```

Installation from sources (requiring setuptools):

```python
pip install .
```


## CLI usage

```
odsgenerator [-h] [--version] input_file output_file
```

### arguments


`input_file`: input file containing data in JSON or YAML format

`output_file`: output file, `.ods` file generated from the input

Use ``odsgenerator --help`` for more details about input file parameters
and look at examples in the tests folder.


## Usage from python code

```python
import odsgenerator

content = odsgenerator.ods_bytes([[["a", "b", "c"], [10, 20, 30]]])
with open("sample.ods", "wb") as file:
    file.write(content)
```

The resulting `.ods` file loaded in a spreadsheet:

![spreadsheet screnshot](https://raw.githubusercontent.com/jdum/odsgenerator/main/doc/sample1_ods.png)

Another example with more parameters:

```python
import odsgenerator

content = odsgenerator.ods_bytes(
    [
        {
            "name": "first tab",
            "style": "cell_decimal2",
            "table": [
                {
                    "row": ["a", "b", "c"],
                    "style": "bold_center_bg_gray_grid_06pt",
                },
                [10, 20, 30],
            ],
        }
    ]
)
with open("sample2.ods", "wb") as file:
    file.write(content)
```

The `.ods` file loaded in a spreadsheet, with gray background on first line:

![spreadsheet screnshot](https://raw.githubusercontent.com/jdum/odsgenerator/main/doc/sample2_ods.png)


## Principle

-  A document is a list or dict containing tabs,
-  a tab is a list or dict containing rows,
-  a row is a list or dict containing cells.


## Documentation

See in the `./doc folder:

-  `html/odsgenerator.html`
-  `tutorial.json` or `tutorial.yml` and `tutorial.ods`


## License

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


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jdum/odsgenerator",
    "name": "odsgenerator",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4",
    "maintainer_email": "",
    "keywords": "openDocument,ODF,ods,json,spreadsheet,generator",
    "author": "J\u00e9r\u00f4me Dumonteil",
    "author_email": "jerome.dumonteil@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d5/05/7867f140350dedc412271aa45d8e8a443abb71581d1a9641e88e1679f5fa/odsgenerator-1.9.0.tar.gz",
    "platform": null,
    "description": "# odsgenerator, a .ods generator.\n\nGenerate an OpenDocument Format `.ods` file from a `.json` or `.yaml` file.\n\n\nWhen used as a script, `odsgenerator` parses a JSON or YAML description of\ntables and generates an ODF document using the `odfdo` library.\n\nWhen used as a library, `odsgenerator` parses a Python description of tables\nand returns the ODF content as bytes (ready to be saved as a valid ODF document).\n\n-  The content description can be minimalist: a list of lists of lists,\n-  or description can be complex, allowing styles at row or cell level.\n\nSee also https://github.com/jdum/odsparsator which is doing the reverse\noperation, `.osd` to `.json`.\n\n`odsgenerator` is a `Python3` package, using the [odfdo](https://github.com/jdum/odfdo) library. Current version requires Python >= 3.9, see prior versions for older environments.\n\nProject:\n    https://github.com/jdum/odsgenerator\n\nAuthor:\n    jerome.dumonteil@gmail.com\n\nLicense:\n    MIT\n\n\n## Installation\n\nInstallation from Pypi (recommended):\n\n```python\npip install odsgenerator\n```\n\nInstallation from sources (requiring setuptools):\n\n```python\npip install .\n```\n\n\n## CLI usage\n\n```\nodsgenerator [-h] [--version] input_file output_file\n```\n\n### arguments\n\n\n`input_file`: input file containing data in JSON or YAML format\n\n`output_file`: output file, `.ods` file generated from the input\n\nUse ``odsgenerator --help`` for more details about input file parameters\nand look at examples in the tests folder.\n\n\n## Usage from python code\n\n```python\nimport odsgenerator\n\ncontent = odsgenerator.ods_bytes([[[\"a\", \"b\", \"c\"], [10, 20, 30]]])\nwith open(\"sample.ods\", \"wb\") as file:\n    file.write(content)\n```\n\nThe resulting `.ods` file loaded in a spreadsheet:\n\n![spreadsheet screnshot](https://raw.githubusercontent.com/jdum/odsgenerator/main/doc/sample1_ods.png)\n\nAnother example with more parameters:\n\n```python\nimport odsgenerator\n\ncontent = odsgenerator.ods_bytes(\n    [\n        {\n            \"name\": \"first tab\",\n            \"style\": \"cell_decimal2\",\n            \"table\": [\n                {\n                    \"row\": [\"a\", \"b\", \"c\"],\n                    \"style\": \"bold_center_bg_gray_grid_06pt\",\n                },\n                [10, 20, 30],\n            ],\n        }\n    ]\n)\nwith open(\"sample2.ods\", \"wb\") as file:\n    file.write(content)\n```\n\nThe `.ods` file loaded in a spreadsheet, with gray background on first line:\n\n![spreadsheet screnshot](https://raw.githubusercontent.com/jdum/odsgenerator/main/doc/sample2_ods.png)\n\n\n## Principle\n\n-  A document is a list or dict containing tabs,\n-  a tab is a list or dict containing rows,\n-  a row is a list or dict containing cells.\n\n\n## Documentation\n\nSee in the `./doc folder:\n\n-  `html/odsgenerator.html`\n-  `tutorial.json` or `tutorial.yml` and `tutorial.ods`\n\n\n## License\n\nThis project is licensed under the MIT License (see the\n`LICENSE` file for details).\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generate an OpenDocument Format .ods file from json or yaml file",
    "version": "1.9.0",
    "project_urls": {
        "Homepage": "https://github.com/jdum/odsgenerator",
        "Repository": "https://github.com/jdum/odsgenerator"
    },
    "split_keywords": [
        "opendocument",
        "odf",
        "ods",
        "json",
        "spreadsheet",
        "generator"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "546497ffd86be1546496dd5c9a076d1142d342ca8cd92a42b5842645eb5cc70c",
                "md5": "f58379ea826341d7ad146f0bd60230e7",
                "sha256": "fe0eba38f821465978255b2d4da378e6fe3066bdd5465e1b846afb0121a341d0"
            },
            "downloads": -1,
            "filename": "odsgenerator-1.9.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f58379ea826341d7ad146f0bd60230e7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4",
            "size": 10332,
            "upload_time": "2024-01-28T14:16:06",
            "upload_time_iso_8601": "2024-01-28T14:16:06.167935Z",
            "url": "https://files.pythonhosted.org/packages/54/64/97ffd86be1546496dd5c9a076d1142d342ca8cd92a42b5842645eb5cc70c/odsgenerator-1.9.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d5057867f140350dedc412271aa45d8e8a443abb71581d1a9641e88e1679f5fa",
                "md5": "2adf91b5809d7a11e753b9d42c1d0db0",
                "sha256": "0d5480f5b4feb2ccfd86b132a9689aae8807954d385dda451c6fb21cb62604c9"
            },
            "downloads": -1,
            "filename": "odsgenerator-1.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2adf91b5809d7a11e753b9d42c1d0db0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4",
            "size": 10248,
            "upload_time": "2024-01-28T14:16:07",
            "upload_time_iso_8601": "2024-01-28T14:16:07.939648Z",
            "url": "https://files.pythonhosted.org/packages/d5/05/7867f140350dedc412271aa45d8e8a443abb71581d1a9641e88e1679f5fa/odsgenerator-1.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-28 14:16:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jdum",
    "github_project": "odsgenerator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "odsgenerator"
}
        
Elapsed time: 0.17504s