title: Compare list of shapefile field names located in two separate dictionaries with same key
body: <p>I created two dictionaries, d1 and d2, and both contain the same key. The key is a file path to a shapefile, for example: <code>C:\TestFolder\Folder1\A\address_pt.shp.</code> In addition, d1 has values that are lists of field names contained within the attribute table of the shapefile.</p>
  
  <p>Below is an example of d1 output:</p>
  
  <pre><code>{
      'C:\\TestFolder\\Folder1\\A\\address_pt.shp': [
          'FID', 'SHAPE', 'FULL_ADDRE', 'STREET_ADD', 'CITY_ST_ZI', 'PREFIX_DIR', 
          'HALF_ADDRE', 'HOUSE_NUMB', 'STREET_NAM', 'STREET_TYP', 'SUFFIX_DIR', 
          'UNIT_TYPE', 'UNIT_ID', 'CITY', 'STATE', 'ZIPCODE', 'PARCEL_NUM', 
          'PARCEL_N_1', 'HOUSE_NU_1', 'HOUSE_NU_2', 'STATUS', 'ASSEMBLY_S', 'SENATE',
          'DISTRICT', 'COUNCIL', 'GRIDNUM', 'PHYSICAL_A', 'PUBDATE'
      ], 
      'C:\\TestFolder\\Folder1\\B\\ADDRESS_VALID_POINTS.shp': [
          'FID', 'SHAPE', 'ADD_ID', 'HSE_NUMB', 'SNAM_PREMO', 'SNAM_PREDI', 'SNAME',
          'SNAM_POSTY', 'SNAM_POSDI', 'SNAM_POSMO', 'FULL_STREE', 'SUB_ADD_TY', 
          'SUB_ADD_ID', 'FULL_ADDRE', 'PLACE_NAME', 'FNSB_COMM', 'FECC_COMM',
          'ZIPCODE', 'ADD_TYPE', 'NOTES', 'STATUS', 'MS_EXCEPTI', 'NO_MSAG', 
          'GLOBALID', 'CREATED_US', 'CREATED_DA', 'LAST_EDITE', 'LAST_EDI_1'
      ], 
      'C:\\TestFolder\\Folder1\\E\\Public_Safety_Addresses.shp': [
          'FID', 'SHAPE', 'OBJECTID', 'P_ID', 'ACCOUNT', 'TAXID_LOKI', 'ADRSNUM', 
          'P_ROADNME', 'ROADNME', 'S_ROADNME', 'PS_ROADNME', 'ADRSNUM_S', 'ZIP', 
          'LAT', 'LONG', 'ADDRESS', 'COMMUNITY', 'GLOBALID'
      ]
  }
  </code></pre>
  
  <p>Furthermore, d2 contains a list of field names that are thought to be within the shapefile. Below is an example of d2. Notice that both dictionaries have the same key.</p>
  
  <pre><code>{
      'C:\\TestFolder\\Folder1\\A\\address_pt.shp': [
          'HOUSE_NUMB', 'HALF_ADDRE', 'PREFIX_DIR', 'STREET_NAM', 'STREET_TYP', 
          'SUFFIX_DIR', 'UNIT_TYPE', 'UNIT_ID', ' BUILDINGA', 'STREET_ADD', 'CITY', 
          'STATE', 'ZIPCODE'
      ], 
      'C:\\TestFolder\\Folder1\\B\\ADDRESS_VALID_POINTS.shp': [
          'HSE_NUMB', ' PRETYPEA', 'FULL_STREE', 'SUB_ADD_TY', 'SUB_ADD_ID', 'ZIPCODE'
      ], 
      'C:\\TestFolder\\Folder1\\E\\Public_Safety_Addresses.shp': [
          ' TYPEA', 'OBJECTID', 'ADRSNUM', 'P_ROADNME', 'ROADNME', 'S_ROADNME',
          'ADRSNUM_S', 'ADDRESS', 'COMMUNITY', 'ZIP'
      ]
  }
  </code></pre>
  
  <p>My goal is to use the list of field names in d2 and search through d1 to see if field names from d2 exist in d1. I want to create two new dictionaries with the same keys, newd1 will contain field names found and newd2 will contain fields names not found.</p>
  
  <p>In addition, I would like to capture the results of the search and input the results into two new empty fields. The first field would be named something like field_found and include the matching fields found in both dictionaries. The second field would be named something like fields_not_found and include the fields from dictionarytwo that are not found in dictionaryone.</p>
  
  <p>I'm not sure if this process is possible and I can't figure out the code logic. I'm not sure if using dictionaries is the best approach. Below is the code that I currently have and it creates both dictionaries.</p>
  
  <pre><code>import arcpy
  
  #Define the Workspace
  arcpy.env.workspace = r"C:\TestFolder"
  
  dbf1 = "APExistOnlyEdit.dbf"
  myfield = "FI_PATH"
  
  filepathlist2 =[row[0] for row in arcpy.da.SearchCursor(dbf1,myfield)]
  #print(filepathlist2)
  
  #Dictionary one holding Field Names that are within Shapefile
  d1 = {}
  
  for thisFile in filepathlist2:
      ContainedFieldNames = [f.name.upper() for f in arcpy.ListFields(thisFile)]
      d1[thisFile] = ContainedFieldNames
  
  print(d1)
  
  #Dictionary two holding Field Names that are thought to be in Shapefile
  d2 = {}
  
  with arcpy.da.SearchCursor(dbf1, [
      myfield,'AP_FIPS','AP_BLDGCOM','AP_TYPE','AP_STATUS','AP_ID','AP_HOUSENU',
      'AP_HALFADD', 'AP_PREDIR','AP_PRETYPE','AP_STNAME','AP_SUFTYPE','AP_SUFDIR',
      'AP_UNITTYP','AP_UNIT','AP_BUILDIN','AP_FULLADD','AP_CITY','AP_STATE','AP_ZIP'
  ]) as rows:
      for row in rows:    
          d2[row[0]] = [a.upper() for a in row[1:] if a.strip() != '']
  
  print(d2)
  </code></pre>