Open ttngu207 opened 9 months ago
@jkbhagatio The issue seems to be at the Csv
reader. Particularly when the csv file does exist, but the file itself is empty (not sure why, corrupted?).
return pd.read_csv(file, header=0, names=self.columns, dtype=self.dtype, index_col=0)
In that case, the index_col=0
will remove one column.
A fix could be
return pd.read_csv(
file,
header=0,
names=self.columns,
dtype=self.dtype,
index_col=0 if file.stat().st_size else None,
)
Also worth discussing in regards to this issue is whether or not we should find a way to ensure empty files don't make their way into the dataset, on the acquisition side @glopesdev
We should look into https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html to see if this can be resolved via setting pandas args appropriately, that will handle this case of reading from an empty file
Using the aeon api for
reader
andload
, if the returned pd.DataFrame is empty (due to no data found in the specified time period), the empty DataFrame has missing columns.To reproduce the bug
The specified time period has no data, so it is expected for an empty DataFrame being returned. However, this empty df should have the same columns as specified in the reader (
['threshold', 'offset', 'rate']
). However, the returned empty df only has columns:['offset', 'rate']