Skip to content

Commit cdd7550

Browse files
authored
Merge pull request #95 from ecmwf-projects/cdm-csv-tables
Read the new CSV CDM tables.
2 parents 1cb95d4 + 20da822 commit cdd7550

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

cdsobs/cdm/api.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,17 @@ def open_asset(cdm_netcdf: str, decode_variables: bool = False) -> xarray.Datase
263263

264264

265265
def read_cdm_code_table(cdm_tables_location: Path, name: str) -> CDMCodeTable:
266-
table_path = Path(cdm_tables_location, f"cdm-obs/tables/{name}.dat")
266+
table_path = Path(cdm_tables_location, f"cdm-obs/tables/{name}.csv")
267267
table_data = pandas.read_csv(
268268
table_path,
269-
delimiter="\t",
270-
quoting=3,
269+
delimiter=",",
270+
quoting=0,
271271
dtype=str,
272272
na_filter=False,
273273
comment="#",
274274
index_col=0,
275+
engine="python",
276+
on_bad_lines="error",
275277
)
276278
return CDMCodeTable(name, table_data)
277279

cdsobs/cdm/tables.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,14 @@ def read_cdm_table(cdm_tables_location: Path, name: str) -> CDMTable:
179179
table_path = Path(cdm_tables_location, f"cdm-obs/table_definitions/{name}.csv")
180180
table_data = pandas.read_csv(
181181
table_path,
182-
delimiter="\t",
183-
quoting=3,
182+
delimiter=",",
183+
quoting=0,
184184
dtype=str,
185185
na_filter=False,
186186
comment="#",
187187
index_col="element_name",
188+
engine="python",
189+
on_bad_lines="error",
188190
).drop("description", axis=1)
189191
# In some tables kind is called type
190192
if "kind" not in table_data:

tests/cli/test_app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def test_cli_make_cdm(tmp_path):
9292
tmp_path,
9393
"--source",
9494
"OzoneSonde",
95+
"--disable-cdm-tag-check",
9596
]
9697
result = runner.invoke(app, args, catch_exceptions=False)
9798
assert result.exit_code == 0

0 commit comments

Comments
 (0)