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>
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 on around a hundred sample files I found on the internet. For the most part, it works well. The known issues right now are:
Read only. No write support.
Can’t read compressed data.
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 doesn’t fall into one of the known issues above 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:
from sas7bdat import SAS7BDAT f = SAS7BDAT('foo.sas7bdat')
Read the data using the readData method:
for line in f.readData(): # do something...
If you’d like to get a pandas DataFrame, use the toDataFrame method:
df = f.toDataFrame()
Project details
Release history Release notifications | RSS feed
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-0.2.4.tar.gz
.
File metadata
- Download URL: sas7bdat-0.2.4.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d54feb5b3aba5c958a7c9d9548c30875e3829710f70450a0662ab2fc80e7dbc0 |
|
MD5 | ec16c2cf0b26d8605724ec6f49dec01c |
|
BLAKE2b-256 | ff41dadf0628235d4ab0649b2d717c8c11f2790f4e7fb5892fd1a8623ce31e98 |