Metadata-Version: 2.4
Name: px2csv
Version: 1.1.0
Summary: Fast and memory-efficient PX to CSV converter
Author: Kusti Aholainen
License-Expression: MIT
Project-URL: Homepage, https://github.com/kustij/pxconvert
Project-URL: Repository, https://github.com/kustij/pxconvert
Keywords: px,pc-axis,csv,statistics
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: C++
Classifier: Programming Language :: Python :: 3
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 :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Text Processing :: Filters
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# px2csv

Convert PX (PC-Axis) files to CSV fast and memory-efficiently in Python.

We currently support only UTF-8 encoded PX files.

### Install from PyPI

```python
pip install px2csv
```

### Convert using file paths

```python
from px2csv import convert
convert("examples/12b4.px", "examples/12b4.csv", include_codes=True, include_labels=True)
```

For large sparse PX files, skip missing values and avoid repeated label columns:

```python
from px2csv import convert
convert(
	"examples/132g.px",
	"examples/132g.csv",
	include_codes=True,
	include_labels=False,
	skip_empty=True,
)
```

### Convert using file-like objects (streams)

```python
import io
from px2csv import convert
with open("examples/12b4.px", "rb") as fin, open("examples/12b4.csv", "wb") as fout:
	convert(fin, fout, include_codes=True, include_labels=True)
```

### Filter rows while converting (`select`)

Pass `select` to keep only the rows you need. Filtering happens inside the C++
converter, so the discarded rows are never materialized.

```python
from px2csv import convert
convert(
	"examples/12b4.px",
	"examples/12b4.csv",
	include_codes=True,
	include_labels=True,
	select={
		"Tiedot": ["arvogwh", "osuuskk"],
		"Vuosi": ["2024", "2023"],
	},
)
```

`select` maps a dimension name to the list of value **codes** to keep; Only rows that match every selected dimension are
emitted; dimensions omitted from `select` are kept in full.
