I am trying to read a Stata (.dta
) file in Python with pandas.read_stata
, But I'm getting this error:
ValueError: Version of given Stata file is not 104, 105, 108, 111 (Stata 7SE), 113 (Stata 8/9), 114 (Stata 10/11), 115 (Stata 12), 117 (Stata 13), or 118 (Stata 14)
Please advise.
If the version of your .dta file is 110 or something else that is not supported by pandas, you can easily use pyreadstat python library. This module is a wrapper around the excellent Readstat C library.
The great thing about pyreadstat is that the library returns pandas dataframe. Here is the snippet:
import pyreadstat
dataframe, meta = pyreadstat.read_dta('Filepath.dta')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With