Skip to content

Commit cc0b35d

Browse files
author
Tom Holland
committed
Refactor column selection before biologic import
1 parent 2844b2c commit cc0b35d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pyprobe/cyclers/biologic.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ def read_file(filepath: str) -> pl.DataFrame:
5656
all_columns = pl.scan_csv(
5757
filepath, skip_rows=n_header_lines - 1, separator="\t"
5858
).columns
59-
selected_columns = [
60-
col for col in all_columns if any(sub in col for sub in columns_to_read)
61-
]
59+
selected_columns = []
60+
for substring in columns_to_read:
61+
found_columns = [col for col in all_columns if substring in col]
62+
selected_columns.extend(found_columns)
63+
6264
dataframe = pl.read_csv(
6365
filepath,
6466
skip_rows=n_header_lines - 1,
@@ -70,7 +72,10 @@ def read_file(filepath: str) -> pl.DataFrame:
7072
dataframe = dataframe.with_columns(
7173
(pl.col("time/s") * 1000000 + start).cast(pl.Datetime).alias("Date")
7274
)
75+
76+
7377
return dataframe
78+
7479

7580
@classmethod
7681
def sort_files(cls, file_list: List[str]) -> List[str]:

0 commit comments

Comments
 (0)