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