seanpedrickcase commited on
Commit
27640cb
·
1 Parent(s): adb8925

Added even more checks on ref_df

Browse files
Files changed (1) hide show
  1. tools/matcher_funcs.py +6 -3
tools/matcher_funcs.py CHANGED
@@ -418,8 +418,11 @@ def check_ref_data_exists(Matcher:MatcherClass, ref_data_state:PandasDataFrame,
418
  #print("Matcher reference file: ", Matcher.ref_df['Reference file'])
419
 
420
  # Check if the source is the Addressbase places API
421
- if Matcher.ref_df is not None and len(Matcher.ref_df) > 0 and 'Reference file' in Matcher.ref_df.columns:
422
- if Matcher.ref_df.iloc[0]['Reference file'] == 'API' or '_api_' in Matcher.ref_df.iloc[0]['Reference file']:
 
 
 
423
  Matcher.ref_df = Matcher.ref_df.rename(columns={
424
  "ORGANISATION_NAME": "Organisation",
425
  "ORGANISATION": "Organisation",
@@ -440,7 +443,7 @@ def check_ref_data_exists(Matcher:MatcherClass, ref_data_state:PandasDataFrame,
440
  "TOWN_NAME":"PostTown",
441
  "LOCALITY_NAME":"LocalityName",
442
  "ADMINISTRATIVE_AREA":"AdministrativeArea"
443
- }, errors="ignore")
444
 
445
  # Check ref_df file format
446
  # If standard format, or it's an API call
 
418
  #print("Matcher reference file: ", Matcher.ref_df['Reference file'])
419
 
420
  # Check if the source is the Addressbase places API
421
+ if Matcher.ref_df is not None and len(Matcher.ref_df) > 0:
422
+ first_row = Matcher.ref_df.iloc[0]
423
+ print(first_row)
424
+ if first_row is not None and 'Reference file' in first_row:
425
+ if first_row['Reference file'] == 'API' or '_api_' in first_row['Reference file']:
426
  Matcher.ref_df = Matcher.ref_df.rename(columns={
427
  "ORGANISATION_NAME": "Organisation",
428
  "ORGANISATION": "Organisation",
 
443
  "TOWN_NAME":"PostTown",
444
  "LOCALITY_NAME":"LocalityName",
445
  "ADMINISTRATIVE_AREA":"AdministrativeArea"
446
+ }, errors="ignore")
447
 
448
  # Check ref_df file format
449
  # If standard format, or it's an API call