Skip to content

Commit c3d1c3d

Browse files
committed
Update readers.py
Load with polars then convert to np, saves some time
1 parent 0e7cf0e commit c3d1c3d

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/wristpy/io/readers/readers.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,16 @@ def _read_actigraph_csv(filepath: pathlib.Path) -> tuple[np.ndarray, dict]:
211211
f"{start_date} {start_time}", "%d/%m/%Y %H:%M:%S"
212212
)
213213

214-
data = np.loadtxt(
214+
data = pl.read_csv(
215215
filepath,
216-
delimiter=",",
217-
skiprows=12,
218-
usecols=(0, 1, 2),
219-
)
216+
skip_rows=12,
217+
has_header=False,
218+
schema_overrides={
219+
"Accelerometer_X": pl.Float64,
220+
"Accelerometer_Y": pl.Float64,
221+
"Accelerometer_Z": pl.Float64,
222+
},
223+
).to_numpy()
220224

221225
metadata = {"sampling_rate": sampling_rate, "start_datetime": start_datetime}
222226

0 commit comments

Comments
 (0)