Metadata-Version: 2.4
Name: pyodsstream
Version: 0.0.7
Summary: Stream API to read and write Open Document Spreadsheet (ODS) or TSV files.
Author: Olivier Langella
Author-email: Olivier Langella <olivier.langella@cnrs.fr>
License-Expression: GPL-3.0-or-later
Project-URL: source, https://codeberg.org/PAPPSO/pyodsstream
Project-URL: tracker, https://codeberg.org/PAPPSO/pyodsstream/issues
Keywords: stream,OpenDocument,data table
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: license-file

# pyodsstream

Simple python API to handle ODS and tabulated files as streams. It provides lazy methods to read and write Open Document Spreadsheet or TSV files saving memory: data can be treated on the fly without having to load the entire tables.

## Simple usage: write an ODS file

```python
from pyodsstream import OdsDocWriter

ods_file = "test.ods"
with open(ods_file, "wb") as fp:
    writer = OdsDocWriter(fp)
    writer.write_sheet("This is a new sheet")
    writer.write_cell("This is a cell")
    writer.write_cell(15)
    writer.write_line()
    writer.write_cell("This is a cell on the second line")
    writer.close()
```

## Simple usage: read this ODS file

```python
from pyodsstream import OdsDocReader

ods_file = "test.ods"
reader = OdsDocReader()
with open(ods_file, "rb") as fp:
    reader.parse(fp)
    for sheet_line in reader.yield_sheet_lines():
        # sheet_line is a dictionnary:
        # {'sheet': 'This is a new sheet', 'line': ['This is a cell', 15.0]}
        if sheet_line["sheet"] == "This is a new sheet" and reader.line_position() == 0:
            assert sheet_line["line"][0] == 'This is a "cell with a quote'
```

## Write your table to any CalcWriterInterface

```python
from pyodsstream import CalcWriterInterface, OdsDocWriter, TsvDirectoryWriter

def write_your_table(writer: CalcWriterInterface):
    writer.write_sheet("This is a new sheet")
    writer.write_cell("This is a cell")
    writer.write_cell(15)
    writer.write_line()
    writer.write_cell("This is a cell on the second line")
    writer.close()


ods_file = "test.ods"
with open(ods_file, "wb") as fp:
    writer = OdsDocWriter(fp)
    write_your_table(writer)

tsv_directory = "test.d"
writer = TsvDirectoryWriter(tsv_directory)
write_your_table(writer)
```
