From f5cc332a885064dca2e19713d208e4ae1ca59770 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 16 Dec 2024 08:07:14 +0100 Subject: [PATCH] fixing check factor schema errors --- rowers/dataroutines.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/rowers/dataroutines.py b/rowers/dataroutines.py index d34a1a3e..a47521d5 100644 --- a/rowers/dataroutines.py +++ b/rowers/dataroutines.py @@ -1648,10 +1648,14 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False, datadf = pl.concat(data) existing_columns = [col for col in columns if col in datadf.columns] datadf = datadf.select(existing_columns) - except (ShapeError, SchemaError, ColumnNotFoundError): - data = [ - df.select(columns) - for df in data] + except (ShapeError, SchemaError): + try: + data = [ + df.select(columns) + for df in data] + except ColumnNotFoundError: + existing_columns = [col for col in columns if col in df.columns] + df = df.select(existing_columns) # float columns floatcolumns = [] @@ -1686,14 +1690,19 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False, ] except ComputeError: pass + except ColumnNotFoundError: + pass try: datadf = pl.concat(data) except SchemaError: - data = [ - df.with_columns(cs.integer().cast(pl.Float64)) for df in data - ] - datadf = pl.concat(data) + try: + data = [ + df.with_columns(cs.integer().cast(pl.Float64)) for df in data + ] + datadf = pl.concat(data) + except ShapeError: + return pl.DataFrame()