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