Skip to content

Commit c6f832a

Browse files
fix: ChemoMetec Nucleoview - wrap key error when indexing dataframe (#1006)
Co-authored-by: Nathan Stender <nathan.stender@benchling.com>
1 parent 95682d3 commit c6f832a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/allotropy/parsers/chemometec_nucleoview/nucleoview_reader.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pandas as pd
22

3-
from allotropy.exceptions import AllotropeConversionError
3+
from allotropy.exceptions import AllotropeConversionError, AllotropeParsingError
44
from allotropy.parsers.utils.pandas import assert_not_empty_df, read_csv
55
from allotropy.types import IOType
66

@@ -13,7 +13,12 @@ def read(cls, contents: IOType) -> pd.DataFrame:
1313
df = read_csv(
1414
contents, sep="[;,]+", engine="python", skipinitialspace=True, index_col=0
1515
)
16-
df = df[:-1].dropna(axis="index", how="all").T
16+
try:
17+
df = df[:-1].dropna(axis="index", how="all").T
18+
except KeyError as e:
19+
msg = f"Error processing CSV data structure. The file may be corrupted or have an invalid format: {e}"
20+
raise AllotropeParsingError(msg) from e
21+
1722
df = df.rename(
1823
{"Estimated cell diameter [um]": "Estimated cell diameter (um)"},
1924
axis="columns",

0 commit comments

Comments
 (0)