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