Using the paths#

path is the main file of a dataset, as a pathlib.Path. Use it to test a file loader against a real file.

from nbdemo.data.aero import flight_dc

flight_dc.path
PosixPath('/home/runner/work/nbdemo/nbdemo/src/nbdemo/data/aero/flight_dc/telemetry.csv')

Pass it to the loader you are testing. This one is pandas.read_csv:

import pandas as pd

pd.read_csv(flight_dc.path).head(3)
time latitude longitude altitude heading track groundspeed airspeed vertical_speed pitch roll throttle engine_rpm fuel outside_air_temp bus_voltage
0 2026-01-01T12:00:00.000000Z 38.8512 -77.0402 5.0 10.0 0.0 0.0 0.0 0.0 0.0609 -0.3120 12.3752 1042.1085 79.9999 21.9024 13.7609
1 2026-01-01T12:00:00.100000Z 38.8512 -77.0402 5.0 10.0 0.0 0.0 0.0 0.0 0.0256 -0.0949 11.9916 1015.2043 79.9997 22.0440 13.8233
2 2026-01-01T12:00:00.200000Z 38.8512 -77.0402 5.0 10.0 0.0 0.0 0.0 0.0 0.0132 0.3382 12.2338 1015.1106 79.9996 22.0184 13.7712

Datasets with several files#

Some formats keep their data in more than one file. For ecg_mitbih_119, path is the header, and the signals and annotations are beside it. paths lists all of them by name:

from nbdemo.data.med import ecg_mitbih_119

ecg_mitbih_119.paths
{'119.atr': PosixPath('/home/runner/work/nbdemo/nbdemo/src/nbdemo/data/med/ecg_mitbih_119/119.atr'),
 '119.dat': PosixPath('/home/runner/work/nbdemo/nbdemo/src/nbdemo/data/med/ecg_mitbih_119/119.dat'),
 '119.hea': PosixPath('/home/runner/work/nbdemo/nbdemo/src/nbdemo/data/med/ecg_mitbih_119/119.hea')}

The files are in one folder, so a loader that finds the other files from the main file works unchanged:

import wfdb

wfdb.rdrecord(str(ecg_mitbih_119.path.with_suffix(""))).sig_name
['MLII', 'V1']

Large files#

Using path or paths downloads whatever is missing. The .sigmf-data file of sigmf_synthetic is 8 MB, so it downloads the first time, to the cache. is_local says whether a dataset’s files are all present:

from nbdemo.data.rf import sigmf_synthetic

print(sigmf_synthetic.is_local)  # False until a path is used
meta = sigmf_synthetic.path  # downloads the recording
print(sigmf_synthetic.is_local)
sorted(p.name for p in meta.parent.iterdir())
False
True
['synthetic.sigmf-data', 'synthetic.sigmf-meta']