Stream API to read and write Open Document Spreadsheet (ODS) or TSV files.
Project description
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
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
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
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyodsstream-0.0.7.tar.gz.
File metadata
- Download URL: pyodsstream-0.0.7.tar.gz
- Upload date:
- Size: 33.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cc91698ca413916ca687836485c7fbffa4180dd8f20115ba6a6f2a9c7de7e36
|
|
| MD5 |
a830aee570b2db76998eeea42942f344
|
|
| BLAKE2b-256 |
b654e5cac7e8e8c76f2804588e579f6f968900b334dca7b88b555880d327c41c
|
File details
Details for the file pyodsstream-0.0.7-py3-none-any.whl.
File metadata
- Download URL: pyodsstream-0.0.7-py3-none-any.whl
- Upload date:
- Size: 40.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dadecbc2d28c15f350dbbf2645a4786b37e5483157ed843c57d33d48f41eae55
|
|
| MD5 |
ffc95f51f6399b15a37439f2ce5d5c8d
|
|
| BLAKE2b-256 |
8b89f4c0a00aff82ec8c87069e973137e560c67214ed18ad69331435b03d8456
|