Skip to content

Commit 95f8ecc

Browse files
committed
Make sure obs_links contains required columns
1 parent 85f64eb commit 95f8ecc

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

schimpy/station.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@ def merge_station_subloc(station_dbase, station_subloc, default_z):
410410

411411
def read_obs_links(fpath):
412412
"""Read an obs_links csv file which has comma as delimiter and (id,subloc,variable) as index"""
413+
414+
actual_columns = pd.read_csv(fpath, nrows=0).columns.tolist()
415+
assert set(["station_id", "subloc", "variable"]).issubset(
416+
actual_columns
417+
), f"The 'obs_links' file '{fpath}' must have columns: 'station_id', 'subloc', and 'variable'. Found: {actual_columns}"
418+
413419
df = pd.read_csv(
414420
fpath,
415421
sep=",",

0 commit comments

Comments
 (0)