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.9.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 svy-io 0.9.0
File Size Uploaded Provenance Actions
svy_io-0.9.0.tar.gz 322.8 kB With provenance Details for svy_io-0.9.0.tar.gz

Built distributions (wheels)

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

Total release size: 8.1 MB

Release files / svy_io-0.9.0.tar.gz

Download URL svy_io-0.9.0.tar.gz
Size 322.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ac897713867fe575d27347492d921608d3e4237a8afec9b8ac845a801bf713d4
BLAKE2b-256 checksum
How to use checksums
f61ae21771506de1af6b8b96038c00a283505e6a0f1d299e126c118382500821
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 Nov 3, 2026.

Transparency log

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

Download URL svy_io-0.9.0-cp311-abi3-win_amd64.whl
Size 1.5 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ef85c1105bac4d1a31446f2c04d7bb83d100213e7dfdeb34d8f71313e903fc8d
BLAKE2b-256 checksum
How to use checksums
675d682d98382d6a544a5e7f286873e4be426adbf6ddc3ed8553e091ec00058f
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 Nov 3, 2026.

Transparency log

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

Download URL svy_io-0.9.0-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
1b05e68f4f94020c4aa3e1b136986a15ef1b44a4ed84e8a8269e28e21c8f898b
BLAKE2b-256 checksum
How to use checksums
7a0f85266dc36ff229bac3a18aed5f5ce7e60c44145e7df9f1116950df592b8b
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 Nov 3, 2026.

Transparency log

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

Download URL svy_io-0.9.0-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
9591af50d640254983345fd9be479ff628bb718b2eace1135255a9348dc50e17
BLAKE2b-256 checksum
How to use checksums
64164cc795de9d29b2589c0b1f379ecd92ab4ad826cf822b57ea825bd483c00c
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 Nov 3, 2026.

Transparency log

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

Download URL svy_io-0.9.0-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
a2b0f9f9665db2c814793b6aec3bc33665d03b449198db305df85fbe63913b49
BLAKE2b-256 checksum
How to use checksums
41c5708606adb56e3c77e63096245a4ae33671377d834c9eee87d0a1749c4f73
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 Nov 3, 2026.

Transparency log

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

Download URL svy_io-0.9.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 1.6 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d15f4b42ce1bef4acc10629a3911ee2eb63e92709a9ccfdb13421d01c0e36acf
BLAKE2b-256 checksum
How to use checksums
20c1f66402c1160f281dcf375abcd9a713ee7870fb4c5885558a5da56d4f6b5a
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 Nov 3, 2026.

Transparency log

Security for svy-io 0.9.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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for svy_io-0.9.0.tar.gz

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 Nov 3, 2026.

Transparency log

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