Skip to main content

polars_io

Lazily read Stata (.dta), SAS (.sas7bdat, .xpt), fixed-width (.txt, .dat, etc.), and newline delimited (.txt) files in polars.

Installation

pip install polars_io
# Or:
uv add polars_io

Usage

import polars as pl
import polars_io as pio

# Lazily load a sas file.
lf = pio.scan_sas7bdat("huge_SAS_file.sas7bdat")

# Get its schema.
lf.collect_schema()

# Take a look at the first few rows.
lf.head().collect()

# Projection and predicate pushdown work!
(
    lf
    .filter(pl.col("birth_year").is_between(2000, 2010))
    .select(pl.col("usage").mean())
    .collect()
)

# Load fixed-width files.
col_locations = {"year": (10, 14), "population": (14, 20)}
pio.scan_fwf("populations.txt", col_locations)

# Eager versions of all functions are also available.
pio.read_dta("mortality_rates.dta")

See the documentation for more info.

Details

The Stata and SAS implementations make use of the readstat C library via the Python bindings provided by pyreadstat. For numeric types, reading uses zero-copy conversions from numpy -> pyarrow -> polars and should be faster and have lower memory overhead than reading the data into pandas and then calling pl.from_pandas (benchmarks welcome).

Contributing

PRs adding support for reading other formats are very welcome! (E.g., .Rdata, Stata .dct, SPSS files, etc.)

Known Issues

This packages fails to some read files with non-utf8 metadata (e.g., column labels, notes on .dta files). This is a known issue with upstream packages that is being worked on (see Roche/pyreadstat#298 and WizardMac/ReadStat#344).

Metadata

Release files for polars-io 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polars-io 0.5.0
File Size Uploaded Provenance Actions
polars_io-0.5.0.tar.gz 64.6 kB Without provenance Details for polars_io-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for polars-io 0.5.0
File Interpreter ABI Platform Actions
polars_io-0.5.0-py3-none-any.whl Python 3 none any Details for polars_io-0.5.0-py3-none-any.whl

Total release size: 73.6 kB

Release files / polars_io-0.5.0.tar.gz

Download URL polars_io-0.5.0.tar.gz
Size 64.6 kB
Tags Source
SHA-256 checksum
How to use checksums
120cf441a8caa48d2ea1b76101f712db9bbd6298fe8b36d0f028f4d801c9c0a5
BLAKE2b-256 checksum
How to use checksums
63dc3f3cf72df75631acc9b0ffe068359817fe6db913addff326db19a2951506
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.4

Release files / polars_io-0.5.0-py3-none-any.whl

Download URL polars_io-0.5.0-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aee49129f60449593b200c76e9857943def878115b323359d1df2c69738a5fcc
BLAKE2b-256 checksum
How to use checksums
5bcc13c95ad3fc5c55e79a87d71af50ecf1d0cd30047035d9534d3ddefe62bbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.4

Security for polars-io 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page