@@ -1699,7 +1699,6 @@ def read(
1699
1699
if (self ._nobs == 0 ) and (nrows is None ):
1700
1700
self ._can_read_value_labels = True
1701
1701
self ._data_read = True
1702
- self .close ()
1703
1702
return DataFrame (columns = self ._varlist )
1704
1703
1705
1704
# Handle options
@@ -1736,7 +1735,6 @@ def read(
1736
1735
# we are reading the file incrementally
1737
1736
if convert_categoricals :
1738
1737
self ._read_value_labels ()
1739
- self .close ()
1740
1738
raise StopIteration
1741
1739
offset = self ._lines_read * dtype .itemsize
1742
1740
self ._path_or_buf .seek (self ._data_location + offset )
@@ -1769,11 +1767,7 @@ def read(
1769
1767
data .index = Index (rng ) # set attr instead of set_index to avoid copy
1770
1768
1771
1769
if columns is not None :
1772
- try :
1773
- data = self ._do_select_columns (data , columns )
1774
- except ValueError :
1775
- self .close ()
1776
- raise
1770
+ data = self ._do_select_columns (data , columns )
1777
1771
1778
1772
# Decode strings
1779
1773
for col , typ in zip (data , self ._typlist ):
@@ -1812,13 +1806,9 @@ def any_startswith(x: str) -> bool:
1812
1806
cols = np .where ([any_startswith (x ) for x in self ._fmtlist ])[0 ]
1813
1807
for i in cols :
1814
1808
col = data .columns [i ]
1815
- try :
1816
- data [col ] = _stata_elapsed_date_to_datetime_vec (
1817
- data [col ], self ._fmtlist [i ]
1818
- )
1819
- except ValueError :
1820
- self .close ()
1821
- raise
1809
+ data [col ] = _stata_elapsed_date_to_datetime_vec (
1810
+ data [col ], self ._fmtlist [i ]
1811
+ )
1822
1812
1823
1813
if convert_categoricals and self ._format_version > 108 :
1824
1814
data = self ._do_convert_categoricals (
0 commit comments