Skip to main content

A sas7bdat file reader for Python

Project description

sas7bdat.py

This module will read sas7bdat files using pure Python (2.7+). No SAS software required! The module started out as a port of the R script of the same name found here: <https://github.com/BioStatMatt/sas7bdat> but has since been completely rewritten.

Also included with this library is a simple command line script, sas7bdat_to_csv, which converts sas7bdat files to csv files. It will also print out header information and meta data using the –header option and it will batch convert files as well. Use the –help option for more information.

As is, I’ve successfully tested the script almost three hundred sample files I found on the internet. For the most part, it works well. We can now read compressed files!

I’m sure there are more issues that I haven’t come across yet. Please let me know if you come across a data file that isn’t supported and I’ll see if I can add support for the file.

Usage

To create a sas7bdat object, simply pass the constructor a file path. The object is iterable so you can read the contents like this:

from sas7bdat import SAS7BDAT
with SAS7BDAT('foo.sas7bdat') as f:
    for row in f:
        print row

The values in each row will be a string, float, datetime.date, datetime.datetime, or datetime.time instance.

If you’d like to get a pandas DataFrame, use the to_data_frame method:

df = f.to_data_frame()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sas7bdat-1.0.0.tar.gz (11.4 kB view details)

Uploaded Source

File details

Details for the file sas7bdat-1.0.0.tar.gz.

File metadata

  • Download URL: sas7bdat-1.0.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sas7bdat-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0b3e585d809ed4995c21cdb6bd70546869221384665811af2d68f360bc1719ea
MD5 f253e1ee6b592847249ab1d496b51cdb
BLAKE2b-256 998c3f914847ac6e37f67ca23f2485c0b20fe8ed451159bd57bf05f2239edf32

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page