11import pandas as pd
22
3+ from allotropy .exceptions import AllotropeConversionError
34from allotropy .named_file_contents import NamedFileContents
45from allotropy .parsers .utils .pandas import parse_header_row , read_excel , SeriesData
56
@@ -17,8 +18,19 @@ def __init__(self, named_file_contents: NamedFileContents) -> None:
1718 by finding the index first row which contains the word 'Particle' and ending right before
1819 the index of the first row containing 'Approver'.
1920 """
20- start = df [df [1 ].str .contains ("Particle" , na = False )].index .values [0 ]
21- end = df [df [0 ].str .contains ("Approver_" , na = False )].index .values [0 ] - 1
21+ # Check for rows containing "Particle" in column 1
22+ particle_rows = df [df [1 ].str .contains ("Particle" , na = False )].index .values
23+ if len (particle_rows ) == 0 :
24+ msg = "Unable to find required 'Particle' marker in column 1 of the data file."
25+ raise AllotropeConversionError (msg )
26+ start = particle_rows [0 ]
27+
28+ # Check for rows containing "Approver_" in column 0
29+ approver_rows = df [df [0 ].str .contains ("Approver_" , na = False )].index .values
30+ if len (approver_rows ) == 0 :
31+ msg = "Unable to find required 'Approver_' marker in column 0 of the data file."
32+ raise AllotropeConversionError (msg )
33+ end = approver_rows [0 ] - 1
2234
2335 # The header data is everything up to the start of the data.
2436 # It is stored in two columns spread over the first 6 columns.
0 commit comments