magento
asked on
Stata conversion DTA to CSV
Hi,
How can I convert old version of dta file to excel or csv file. (doing it for my friend)
I checked in GitHub for all Stata file reader and for old version nothing is there.
please advice.
Error for reference
[code]
File "/home/pi/.local/lib/pytho n3.7/site- packages/p andas/io/s tata.py", line 1299, in _read_old_header
raise ValueError(_version_error. format(ver sion=self. format_ver sion))
ValueError: Version of given Stata file is 32. pandas supports importing versions 105, 108, 111 (Stata 7SE), 113 (Stata 8/9), 114 (Stata 10/11), 115 (Stata 12), 117 (Stata 13), 118 (Stata 14/15/16),and 119 (Stata 15/16, over 32,767 variables).
[/code]
code used:
[code]
import pandas as pd
reader=pd.read_stata("DP.D TA",chunks ize=100000 )
df = pd.DataFrame()
for itm in reader:
df=df.append(itm)
df.to_csv("DP.csv")
[/code]
Sample dta file attached.
DP.zip
How can I convert old version of dta file to excel or csv file. (doing it for my friend)
I checked in GitHub for all Stata file reader and for old version nothing is there.
please advice.
Error for reference
[code]
File "/home/pi/.local/lib/pytho
raise ValueError(_version_error.
ValueError: Version of given Stata file is 32. pandas supports importing versions 105, 108, 111 (Stata 7SE), 113 (Stata 8/9), 114 (Stata 10/11), 115 (Stata 12), 117 (Stata 13), 118 (Stata 14/15/16),and 119 (Stata 15/16, over 32,767 variables).
[/code]
code used:
[code]
import pandas as pd
reader=pd.read_stata("DP.D
df = pd.DataFrame()
for itm in reader:
df=df.append(itm)
df.to_csv("DP.csv")
[/code]
Sample dta file attached.
DP.zip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help.
ASKER
I tested it, its working .
But csv file doesnt looks like what i was expecting.
May be i need to check in windows machine , will update you next week.
Many thanks for the help.
Thanks,
Magento