Skip to content

Commit

Permalink
fix: apply dayfirst in special read cases, also in the case of csv files
Browse files Browse the repository at this point in the history
Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x committed Mar 8, 2024
1 parent 31f87c3 commit 43e9e35
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions timely_beliefs/beliefs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,16 +631,15 @@ def read_csv( # noqa C901
if col not in kwargs.get("usecols", [])
]
ext = find_out_extension(path)
dayfirst = None
if ext.lower() == "csv":
df = pd.read_csv(path, **kwargs)
elif ext.lower() in ("xlsm", "xlsx", "xls"):
dayfirst = kwargs.pop("dayfirst", None)
df = pd.read_excel(path, **kwargs) # requires openpyxl
else:
raise TypeError(
f"Extension {ext} not recognized. Accepted file extensions are csv, xlsm, xlsx and xls."
)
dayfirst = kwargs.pop("dayfirst", None)
if filter_by_column:
# Filter the read-in data
for col, val in filter_by_column.items():
Expand Down Expand Up @@ -766,7 +765,7 @@ def interpret_special_read_cases(
sensor: "classes.Sensor",
resample: bool,
timezone: str | None,
dayfirst: bool,
dayfirst: bool | None,
split: str | None = None,
) -> pd.DataFrame:
"""Interpret the read-in data, either as event starts and event values (2 cols),
Expand Down

0 comments on commit 43e9e35

Please sign in to comment.