sas7bdat.py
This module will read sas7bdat files using pure Python (2.6+, 3+). 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:
#!python
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:
#!python df = f.to_data_frame()
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file sas7bdat-2.2.1.tar.gz.
File metadata
- Download URL: sas7bdat-2.2.1.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.10.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/2.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bca352b07a61686eb2b4d636560b5a7ffc1e2004d5e7275968b2fc277615679
|
|
| MD5 |
183e4f2d1f82d0910ab8aba64bb822c7
|
|
| BLAKE2b-256 |
183032c8285114e6bd442c47e862dd5a30d052ab4f65514a09bfcfcdea10c7d6
|