MTSV for Python
A parser and a generator for Multi-Sheet Tab-Separated Values (MTSV), with
integrations for spreadsheets (ODS) and data tools (Apache Arrow). The
version is the version field of pyproject.toml.
Install
From the repository. A Python that an operating system manages does not accept packages directly, so install into a virtual environment. Run these from the root of the repository, one folder above this one:
python3 -m venv .venv
.venv/bin/pip install ./python
For the Arrow integration, which also installs pyarrow:
.venv/bin/pip install "./python[arrow]"
Read and write MTSV
Sheets are a list of dictionaries with "sheet name", "header", and
"records", the same shape as the
conformance results.
import mtsv
with open("book.mtsv", "rb") as file:
sheets = mtsv.load(file)
with open("book.mtsv", "wb") as file:
mtsv.dump(sheets, file)
loads and dumps work on strings.
Spreadsheets (ODS)
from mtsv.integrations import ods
with open("book.ods", "wb") as file:
ods.dump(sheets, file)
with open("book.ods", "rb") as file:
sheets = ods.load(file)
From the command line:
python -m mtsv.integrations.ods book.mtsv book.ods
python -m mtsv.integrations.ods book.ods book.mtsv
Data tools (Apache Arrow)
from mtsv.integrations import arrow
tables = arrow.to_arrow(sheets)
sheets = arrow.from_arrow(tables)
tables is a list of (sheet name, pyarrow.Table) pairs.
What is left behind
MTSV holds sheets, names, rows, and text. Going out to ODS or Arrow keeps all
of it, with two ODS exceptions: characters that XML 1.0 does not allow raise
ValueError, and empty rows and columns at the edge of a sheet do not come
back from ODS, so a sheet of only empty fields comes back as an empty sheet.
Coming back in, anything else (formatting, formulas, types, missing values)
raises ValueError by default. To confirm and leave it behind, pass
errors="ignore", or --errors ignore on the command line. Text that MTSV
cannot hold, such as a tab or line break inside a value, always raises
ValueError. So does an Arrow column whose values cannot be text at all, such
as binary, a list, or a struct.
Layout
| Path | Contents |
|---|---|
src/mtsv/ |
the interface, the parser, and the generator |
src/mtsv/integrations/ |
one module per target standard |
tests/ |
the test suite, run against the install |
Test
From the root of the repository:
.venv/bin/python -m unittest discover -s python/tests
License
Release files for mtsv 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mtsv-0.1.0.tar.gz | 13.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mtsv-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.1 kB
Release files / mtsv-0.1.0.tar.gz
| Download URL | mtsv-0.1.0.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65091c5723786dd0d006fac24623807fe6185f059c98210c9f92f23c267cd2c8
|
|
BLAKE2b-256 checksum How to use checksums |
07675dc56ff26a8e15f535f3dc5f83d7dec9b86924e90c8eb2b9d3d0cc02a39d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / mtsv-0.1.0-py3-none-any.whl
| Download URL | mtsv-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
963f3f0c9d836b344d13bf2d1f6dd1789ba47fb3fbdd2985a53a68ac9c9d0bd7
|
|
BLAKE2b-256 checksum How to use checksums |
a8676b7481a2978c0b207de97705e12f1a3dba3653ba4ce7e8124f094dca753a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|