@@ -1711,7 +1711,6 @@ def read(
17111711 if (self ._nobs == 0 ) and (nrows is None ):
17121712 self ._can_read_value_labels = True
17131713 self ._data_read = True
1714- self .close ()
17151714 return DataFrame (columns = self ._varlist )
17161715
17171716 # Handle options
@@ -1748,7 +1747,6 @@ def read(
17481747 # we are reading the file incrementally
17491748 if convert_categoricals :
17501749 self ._read_value_labels ()
1751- self .close ()
17521750 raise StopIteration
17531751 offset = self ._lines_read * dtype .itemsize
17541752 self ._path_or_buf .seek (self ._data_location + offset )
@@ -1781,11 +1779,7 @@ def read(
17811779 data .index = Index (rng ) # set attr instead of set_index to avoid copy
17821780
17831781 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 )
17891783
17901784 # Decode strings
17911785 for col , typ in zip (data , self ._typlist ):
@@ -1824,13 +1818,9 @@ def any_startswith(x: str) -> bool:
18241818 cols = np .where ([any_startswith (x ) for x in self ._fmtlist ])[0 ]
18251819 for i in cols :
18261820 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+ )
18341824
18351825 if convert_categoricals and self ._format_version > 108 :
18361826 data = self ._do_convert_categoricals (
0 commit comments