Metadata-Version: 2.4
Name: flat-file-renderers
Version: 0.3.0
Summary: Render tabular/nested datasets (list/dict/QuerySet-like) into xlsx, csv, tsv, json, html or parquet files, zipped, with zero required dependencies
Author-email: Kelson da Costa Medeiros <kelsoncm@gmail.com>
License: # License
        
        ## The MIT License (MIT)
        
        Copyright (c) 2026 python-by-kelsoncm
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/python-by-kelsoncm/python-flat-file-renderers
Project-URL: Bug Tracker, https://github.com/python-by-kelsoncm/python-flat-file-renderers/issues
Project-URL: Download, https://github.com/python-by-kelsoncm/python-flat-file-renderers/releases/
Project-URL: Docs, https://python-by-kelsoncm.github.io/python-flat-file-renderers/
Keywords: export,xlsx,csv,tsv,json,html,parquet,renderer,flatten
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.md
License-File: AUTHORS.md
Provides-Extra: xlsx
Requires-Dist: openpyxl>=3.1; extra == "xlsx"
Provides-Extra: parquet
Requires-Dist: pyarrow>=15; extra == "parquet"
Provides-Extra: all
Requires-Dist: openpyxl>=3.1; extra == "all"
Requires-Dist: pyarrow>=15; extra == "all"
Provides-Extra: dev
Requires-Dist: openpyxl>=3.1; extra == "dev"
Requires-Dist: pyarrow>=15; extra == "dev"
Requires-Dist: pre-commit>=4.6.0; extra == "dev"
Requires-Dist: black>=26.3.1; extra == "dev"
Requires-Dist: ruff>=0.15.11; extra == "dev"
Requires-Dist: doc8>=2.0.0; extra == "dev"
Requires-Dist: pytest>=9.0.3; extra == "dev"
Requires-Dist: pytest-cov>=7.1.0; extra == "dev"
Requires-Dist: pytest-coverage-gate>=1.0.3; extra == "dev"
Dynamic: license-file

# flat-file-renderers

[![License](https://img.shields.io/badge/License-MIT-lemon.svg)](https://opensource.org/licenses/MIT)
[![Python](https://img.shields.io/pypi/pyversions/flat-file-renderers.svg)](https://pypi.org/project/flat-file-renderers/)
[![QA](https://github.com/python-by-kelsoncm/python-flat-file-renderers/actions/workflows/qa.yml/badge.svg)](https://github.com/python-by-kelsoncm/python-flat-file-renderers/actions/workflows/qa.yml)
[![Coverage](https://codecov.io/gh/python-by-kelsoncm/python-flat-file-renderers/branch/main/graph/badge.svg)](https://codecov.io/gh/python-by-kelsoncm/python-flat-file-renderers)
[![Publish](https://github.com/python-by-kelsoncm/python-flat-file-renderers/actions/workflows/publish.yml/badge.svg)](https://github.com/python-by-kelsoncm/python-flat-file-renderers/actions/workflows/publish.yml)
[![Docs](https://github.com/python-by-kelsoncm/python-flat-file-renderers/actions/workflows/docs.yml/badge.svg)](https://python-by-kelsoncm.github.io/python-flat-file-renderers/)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

Render tabular/nested datasets - a `list` of dicts, a `dict` of `{"rows": [...], "cols": [...]}`,
a QuerySet-like iterable, or record/model objects - into **xlsx, csv, tsv, json, html or parquet**
files, zipped. Nested lists of dicts are flattened automatically into dot+index-notation columns
(`contacts.1.phone`, `contacts.2.phone`, ...), and a `dict[str, dataset]` renders one file per key
into the same zip (one sheet per key for xlsx, one file per key for the others).

No required dependencies for csv/tsv/json/html. `xlsx` and `parquet` are optional extras.

## Installation

```bash
pip install flat-file-renderers            # csv, tsv, json, html - zero extra dependencies
pip install flat-file-renderers[xlsx]       # + openpyxl, for XlsxRenderer
pip install flat-file-renderers[parquet]    # + pyarrow, for ParquetRenderer
pip install flat-file-renderers[all]        # everything
```

## Quick start

```python
from flat_file_renderers import CsvRenderer

renderer = CsvRenderer({})
zip_path = renderer.render({"dataset": [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]})
# zip_path -> Path to a .zip containing one .csv
```

```python
from flat_file_renderers.xlsx import XlsxRenderer  # requires the "xlsx" extra

renderer = XlsxRenderer({})
zip_path = renderer.render({"dataset": {"Students": [{"name": "Alice"}], "Courses": [{"title": "Python"}]}})
# zip_path -> Path to a .zip containing one .xlsx with two sheets
```

Every renderer shares the same interface (`BaseRenderer.render(context) -> Path`, where
`context["dataset"]` holds the data), so switching output formats is a one-line change:

```python
from flat_file_renderers import CsvRenderer, TsvRenderer, JsonRenderer, HtmlRenderer
from flat_file_renderers.xlsx import XlsxRenderer
from flat_file_renderers.parquet import ParquetRenderer

for Renderer in (CsvRenderer, TsvRenderer, JsonRenderer, HtmlRenderer, XlsxRenderer, ParquetRenderer):
    zip_path = Renderer({}).render({"dataset": rows})
```

Runnable examples for every renderer live in [`sandbox/`](sandbox/).

## Modules

* `flat_file_renderers.base` - `BaseRenderer`, `ZipFileEntry`
* `flat_file_renderers.flat_dict_list_helper` - `FlatDictListHelper`, the flattening engine shared
  by every renderer
* `flat_file_renderers.separated_value` - `CsvRenderer`, `TsvRenderer`
* `flat_file_renderers.json` - `JsonRenderer` (JSON Lines/NDJSON: one object per line, `.jsonl`)
* `flat_file_renderers.html` - `HtmlRenderer`
* `flat_file_renderers.xlsx` - `XlsxRenderer` (extra: `xlsx`)
* `flat_file_renderers.parquet` - `ParquetRenderer` (extra: `parquet`)

See the [documentation](https://python-by-kelsoncm.github.io/python-flat-file-renderers/) for
details and more examples.

## Security

Please report vulnerabilities according to [SECURITY.md](SECURITY.md).

## Author

Kelson da Costa Medeiros <kelsoncm@gmail.com>
