Skip to main content

svy-io

Lightweight, Pythonic file I/O for SAS, SPSS, and Stata powered by the ReadStat C library. Returns Polars DataFrames and preserves useful metadata — with a tiny, consistent API.

📘 Documentation: svylab.com/docs/svy-io 📊 Analyse the data as a survey with svy 📦 Source: github.com/samplics-org/svy


Installation

pip install svy-io

Requires: Python, Polars, and pyarrow (installed automatically as a dependency).


What you get

  • SAS: read .sas7bdat and .xpt; write .xpt
  • SPSS: read .sav, .zsav, .por; write .sav (incl. .zsav via compress="zsav")
  • Stata: read & write .dta (v8–15)
  • Polars-first: fast DataFrames; each read_* returns (df, meta)

Usage

Below are the only things you need: read_* and write_*.

SAS

# Read
from svy_io.sas import read_sas, read_xpt

df, meta = read_sas("data.sas7bdat")              # optional: catalog_path="formats.sas7bcat"
df_xpt, meta_xpt = read_xpt("transport.xpt")

# Write (XPT v8 recommended)
from svy_io.sas import write_xpt
import polars as pl

df_out = pl.DataFrame({"id": [1, 2, 3], "score": [10.5, 9.3, 8.8]})
write_xpt(df_out, "output.xpt", version=8, label="Study Data")

SPSS

# Read
from svy_io.spss import read_sav, read_por, read_spss

df_sav, meta_sav = read_sav("survey.sav")         # .zsav handled automatically
df_por, meta_por = read_por("legacy.por")
df_auto, meta_auto = read_spss("data.sav")        # auto by extension

# Write
from svy_io.spss import write_sav
import polars as pl

df = pl.DataFrame({"subject_id": [1, 2, 3], "age": [25, 30, 35], "gender": [1, 2, 1]})

write_sav(
    df,
    "out.sav",                 # or "out.zsav" with compress="zsav"
    compress="byte",
    var_labels={"age": "Age (years)", "gender": "Gender"},
    value_labels=[{"col": "gender", "labels": {"1": "Male", "2": "Female"}}],
    user_missing=[{"col": "age", "values": [-99]}]
)

Stata

# Read
from svy_io.stata import read_dta

df, meta = read_dta("data.dta")

# Write
from svy_io.stata import write_dta
import polars as pl

df_out = pl.DataFrame({"id": [1, 2, 3], "income": [50000, 62000, 58000]})

write_dta(
    df_out,
    "output.dta",
    version=14,                              # 8–15; default writes format 118
    file_label="Survey Data 2024",
    var_labels={"income": "Annual income (USD)"}
)

Notes & tips

  • All readers return a tuple: (df: polars.DataFrame, meta: dict).
  • If you work with dates, many read_* functions support coerce_temporals=True.
  • For large files, consider cols_skip=[...] and/or n_max=... while exploring.
  • Stata limits strings to 2045 bytes; SAS XPT v5 has stricter name/length limits — prefer XPT v8 unless you need legacy compatibility.

Metadata

Release files for svy-io 0.7.1

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

Source distribution (sdist)

Source distribution for svy-io 0.7.1
File Size Uploaded
svy_io-0.7.1.tar.gz 315.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for svy-io 0.7.1
File
svy_io-0.7.1-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
svy_io-0.7.1-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
svy_io-0.7.1-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
svy_io-0.7.1-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
svy_io-0.7.1-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 8.0 MB

Release files / svy_io-0.7.1.tar.gz

Download URL svy_io-0.7.1.tar.gz
Size 315.5 kB
Tags Source
SHA-256 checksum
How to use checksums
44952710d6072c27e69fdeff6e6a63a470461f031761aca6b4846298e54748bc
BLAKE2b-256 checksum
How to use checksums
84ce97857fd48e135b7356e356cf58cd6b017e53aeb67fa091ecf7265d2420a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / svy_io-0.7.1-cp311-abi3-win_amd64.whl

Download URL svy_io-0.7.1-cp311-abi3-win_amd64.whl
Size 1.5 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
09d804b7d12a0f688420a2ac3c0e67962a88a5fc6291fbb65012f283452a9e97
BLAKE2b-256 checksum
How to use checksums
6c70942e6b785293e2a007a41203ab426c599495d3c5e99b95afc0c9273614ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / svy_io-0.7.1-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL svy_io-0.7.1-cp311-abi3-manylinux_2_28_x86_64.whl
Size 1.6 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
b49c257b7d7764be1b3886ac3d430ebc3d54332882389c8c589014a8da681a27
BLAKE2b-256 checksum
How to use checksums
4cbd63e8bd1094c46ef3b992e9278124bb3f9b110ba16023d362ebdd9489f6ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / svy_io-0.7.1-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL svy_io-0.7.1-cp311-abi3-manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
53a67328bce14e0fa89cdcc34cb395b81bb60f180701059907eb8e9a2254c8f6
BLAKE2b-256 checksum
How to use checksums
72e8c2313e97b07ae4c3e63297f518086d5ef2c36f775e2b18e20cec8152c824
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / svy_io-0.7.1-cp311-abi3-macosx_11_0_arm64.whl

Download URL svy_io-0.7.1-cp311-abi3-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a43575a645bee182d26c45349ea742fa7a193c86529cc25516b713ccb2dc556c
BLAKE2b-256 checksum
How to use checksums
5729d2c3367096f5a71eef0fff35ce63a11e736d0e5f7df3eb8c9549309c70cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log

Release files / svy_io-0.7.1-cp311-abi3-macosx_10_12_x86_64.whl

Download URL svy_io-0.7.1-cp311-abi3-macosx_10_12_x86_64.whl
Size 1.5 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
bbc2ef4279eadf88e7f9e2588f62b885526a9b68358737717336aac6d1f6fba2
BLAKE2b-256 checksum
How to use checksums
b26675a6d46a3bf2b4934835da236589f7b0e55e5f968817d3263fd14f3da536
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.

Transparency log
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