@@ -1710,7 +1710,6 @@ def read(
1710
1710
if (self ._nobs == 0 ) and (nrows is None ):
1711
1711
self ._can_read_value_labels = True
1712
1712
self ._data_read = True
1713
- self .close ()
1714
1713
return DataFrame (columns = self ._varlist )
1715
1714
1716
1715
# Handle options
@@ -1747,7 +1746,6 @@ def read(
1747
1746
# we are reading the file incrementally
1748
1747
if convert_categoricals :
1749
1748
self ._read_value_labels ()
1750
- self .close ()
1751
1749
raise StopIteration
1752
1750
offset = self ._lines_read * dtype .itemsize
1753
1751
self ._path_or_buf .seek (self ._data_location + offset )
@@ -1780,11 +1778,7 @@ def read(
1780
1778
data .index = Index (rng ) # set attr instead of set_index to avoid copy
1781
1779
1782
1780
if columns is not None :
1783
- try :
1784
- data = self ._do_select_columns (data , columns )
1785
- except ValueError :
1786
- self .close ()
1787
- raise
1781
+ data = self ._do_select_columns (data , columns )
1788
1782
1789
1783
# Decode strings
1790
1784
for col , typ in zip (data , self ._typlist ):
@@ -1823,13 +1817,9 @@ def any_startswith(x: str) -> bool:
1823
1817
cols = np .where ([any_startswith (x ) for x in self ._fmtlist ])[0 ]
1824
1818
for i in cols :
1825
1819
col = data .columns [i ]
1826
- try :
1827
- data [col ] = _stata_elapsed_date_to_datetime_vec (
1828
- data [col ], self ._fmtlist [i ]
1829
- )
1830
- except ValueError :
1831
- self .close ()
1832
- raise
1820
+ data [col ] = _stata_elapsed_date_to_datetime_vec (
1821
+ data [col ], self ._fmtlist [i ]
1822
+ )
1833
1823
1834
1824
if convert_categoricals and self ._format_version > 108 :
1835
1825
data = self ._do_convert_categoricals (
0 commit comments