Skip to content

Commit 3533134

Browse files
committed
ENH: Add support for reading 110-format Stata dta files
1 parent ca55d77 commit 3533134

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

pandas/io/stata.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191

9292
_version_error = (
9393
"Version of given Stata file is {version}. pandas supports importing "
94-
"versions 105, 108, 111 (Stata 7SE), 113 (Stata 8/9), "
94+
"versions 105, 108, 110 (Stata 7), 111 (Stata 7SE), 113 (Stata 8/9), "
9595
"114 (Stata 10/11), 115 (Stata 12), 117 (Stata 13), 118 (Stata 14/15/16),"
9696
"and 119 (Stata 15/16, over 32,767 variables)."
9797
)
@@ -1393,7 +1393,7 @@ def _get_seek_variable_labels(self) -> int:
13931393

13941394
def _read_old_header(self, first_char: bytes) -> None:
13951395
self._format_version = int(first_char[0])
1396-
if self._format_version not in [104, 105, 108, 111, 113, 114, 115]:
1396+
if self._format_version not in [104, 105, 108, 110, 111, 113, 114, 115]:
13971397
raise ValueError(_version_error.format(version=self._format_version))
13981398
self._set_encoding()
13991399
self._byteorder = ">" if self._read_int8() == 0x1 else "<"
@@ -1408,7 +1408,7 @@ def _read_old_header(self, first_char: bytes) -> None:
14081408
self._time_stamp = self._get_time_stamp()
14091409

14101410
# descriptors
1411-
if self._format_version > 108:
1411+
if self._format_version > 110:
14121412
typlist = [int(c) for c in self._path_or_buf.read(self._nvar)]
14131413
else:
14141414
buf = self._path_or_buf.read(self._nvar)
1.48 KB
Binary file not shown.

pandas/tests/io/test_stata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,7 @@ def test_read_write_ea_dtypes(self, dtype_backend, temp_file, tmp_path):
20022002
tm.assert_frame_equal(written_and_read_again.set_index("index"), expected)
20032003

20042004

2005-
@pytest.mark.parametrize("version", [105, 108, 111, 113, 114])
2005+
@pytest.mark.parametrize("version", [105, 108, 110, 111, 113, 114])
20062006
def test_backward_compat(version, datapath):
20072007
data_base = datapath("io", "data", "stata")
20082008
ref = os.path.join(data_base, "stata-compat-118.dta")

0 commit comments

Comments
 (0)