Created
May 22, 2019 09:48
-
-
Save AndreaPasqualini/2b7168dd58e322c11d72b36c3835f5f2 to your computer and use it in GitHub Desktop.
A CLI tool to convert a Stata .dta file into a .csv file. Relies on pandas.
This file contains 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
""" | |
Title: dta_to_csv.py | |
Author: Andrea Pasqualini | |
This CLI tool converts a Stata .dta file into a .csv file. Python3 and pandas | |
are dependencies. It does not return anything, internally. It saves on disk a | |
file with CSV extension that has the same name as the input DTA file. | |
USAGE | |
----- | |
python dta_to_csv.py dtafile.dta | |
""" | |
from sys import argv | |
from pandas import read_stata | |
if __name__ == '__main__': | |
dtaFile = argv[1] | |
fName = dtaFile[ : -4 ] | |
csvFile = fName + '.csv' | |
read_stata( dtaFile ).to_csv( csvFile ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment