Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pandas as pd

from allotropy.exceptions import AllotropeConversionError
from allotropy.exceptions import AllotropeConversionError, AllotropeParsingError
from allotropy.parsers.utils.pandas import assert_not_empty_df, read_csv
from allotropy.types import IOType

Expand All @@ -13,7 +13,12 @@ def read(cls, contents: IOType) -> pd.DataFrame:
df = read_csv(
contents, sep="[;,]+", engine="python", skipinitialspace=True, index_col=0
)
df = df[:-1].dropna(axis="index", how="all").T
try:
df = df[:-1].dropna(axis="index", how="all").T
except KeyError as e:
msg = f"Error processing CSV data structure. The file may be corrupted or have an invalid format: {e}"
raise AllotropeParsingError(msg) from e

df = df.rename(
{"Estimated cell diameter [um]": "Estimated cell diameter (um)"},
axis="columns",
Expand Down
Loading