File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -149,10 +149,11 @@ def ags3_to_brgi_db_mapping(
149149 """
150150 ags3_dfs = ags3_to_dfs (source , encoding )
151151
152- check_ags_proj_group (ags3_dfs ["PROJ" ])
152+ proj_df = ags3_dfs ["PROJ" ]
153+ check_ags_proj_group (proj_df )
153154 ags3_project = ProjectTableMapping (
154- data = ags3_dfs [ "PROJ" ] .to_dict (orient = "records" )[0 ],
155- project_id = ags3_dfs [ "PROJ" ] ["PROJ_ID" ]. iloc [ 0 ],
155+ data = proj_df .to_dict (orient = "records" )[0 ],
156+ project_id = proj_df . at [ proj_df . index [ 0 ], ["PROJ_ID" ]],
156157 horizontal_crs = projected_crs ,
157158 vertical_crs = vertical_crs ,
158159 )
Original file line number Diff line number Diff line change @@ -18,11 +18,14 @@ def check_ags_proj_group(ags_proj: pd.DataFrame) -> bool:
1818 if len (ags_proj ) != 1 :
1919 raise ValueError ("The PROJ group must contain exactly one row." )
2020
21- project_id = ags_proj ["PROJ_ID" ].iloc [0 ]
22- if not project_id :
23- raise ValueError (
24- 'The project ID ("PROJ_ID" in the "PROJ" group) is missing from the AGS data.'
25- )
21+ msg = 'The project ID ("PROJ_ID" in the "PROJ" group) is missing from the AGS data.'
22+ try :
23+ project_id = ags_proj .at [ags_proj .index [0 ], "PROJ_ID" ]
24+ except KeyError :
25+ raise ValueError (msg )
26+
27+ if pd .isna (project_id ) or str (project_id ).strip () == "" :
28+ raise ValueError (msg )
2629
2730 return True
2831
You can’t perform that action at this time.
0 commit comments