Created
April 19, 2018 22:19
-
-
Save alexras/9d2abae541c69a22e982fb4081051de8 to your computer and use it in GitHub Desktop.
Convert sas7bdat file to csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pandas as pd | |
import csv | |
import sys | |
sas = pd.read_sas(sys.argv[1]) | |
with open(sys.argv[1] + '.csv', 'w+') as fp: | |
writer = csv.DictWriter(fp, sas.columns) | |
writer.writeheader() | |
for rowdict in sas.T.to_dict().values(): | |
writer.writerow(rowdict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment