Skip to main content
added 852 characters in body
Source Link
Michael Stimson
  • 25.7k
  • 2
  • 35
  • 75

Perhaps something like this might serve your eventual purpose:

import arcpy

arcpy.env.workspace = r"C:\TestFolder"

#dbf table used for processing
dbf = "ProcessControlTable.dbf" # you don't need the full path because it's in the current workspace
#Column within dbf table containing file paths 
myColumn = "FI_PATH"

arcpy.AddField_management(dbf,'DoesExist','STRING')
with arcpy.da.UpdateCursor(dbf,[myColumn,'DoesExist']) as uCur:
    for uRow in uCur:
        if arcpy.Exists(uRow[0]):
            uRow[1]='1'
        else:
            uRow[1]='0'
        uCur.updateRow(uRow)

# select the non-existing into a new table
arcpy.TableSelect_analysis(dbf,'DataNotExist.dbf',"DoesExist = '0'")

This adds a field 'DoesExist' to your dbf table then iterates the table recording if the dataset is found in the full path and finally extracts a table for just the files that don't exist. Beware though a 2nd iteration will fail at the add field stage as the field already exists.

Another viable option is using a python dictionary, which stores value pairs, in this case (fullPath,Exists) using the full path for the dataset as the key and exists/not exists as the value:

import arcpy

arcpy.env.workspace = r"C:\TestFolder"

#dbf table used for processing
dbf = "ProcessControlTable.dbf" # you don't need the full path because it's in the current workspace
#Column within dbf table containing file paths 
myColumn   = "FI_PATH"
ExistsDict = {}

with arcpy.da.SearchCursor(dbf,myColumn) as sCur:
    for sRow in sCur:
        if arcpy.Exists(sRow[0]):
            ExistsDict[sRow[0]]='1'
        else:
            ExistsDict[sRow[0]]='0'

for FC in ExistsDict: # loop through each dataset path and print if exists
    print '{} exists value {}'.format(ExistsDict[FC])

Perhaps something like this might serve your eventual purpose:

import arcpy

arcpy.env.workspace = r"C:\TestFolder"

#dbf table used for processing
dbf = "ProcessControlTable.dbf" # you don't need the full path because it's in the current workspace
#Column within dbf table containing file paths 
myColumn = "FI_PATH"

arcpy.AddField_management(dbf,'DoesExist','STRING')
with arcpy.da.UpdateCursor(dbf,[myColumn,'DoesExist']) as uCur:
    for uRow in uCur:
        if arcpy.Exists(uRow[0]):
            uRow[1]='1'
        else:
            uRow[1]='0'
        uCur.updateRow(uRow)

# select the non-existing into a new table
arcpy.TableSelect_analysis(dbf,'DataNotExist.dbf',"DoesExist = '0'")

This adds a field 'DoesExist' to your dbf table then iterates the table recording if the dataset is found in the full path and finally extracts a table for just the files that don't exist. Beware though a 2nd iteration will fail at the add field stage as the field already exists.

Perhaps something like this might serve your eventual purpose:

import arcpy

arcpy.env.workspace = r"C:\TestFolder"

#dbf table used for processing
dbf = "ProcessControlTable.dbf" # you don't need the full path because it's in the current workspace
#Column within dbf table containing file paths 
myColumn = "FI_PATH"

arcpy.AddField_management(dbf,'DoesExist','STRING')
with arcpy.da.UpdateCursor(dbf,[myColumn,'DoesExist']) as uCur:
    for uRow in uCur:
        if arcpy.Exists(uRow[0]):
            uRow[1]='1'
        else:
            uRow[1]='0'
        uCur.updateRow(uRow)

# select the non-existing into a new table
arcpy.TableSelect_analysis(dbf,'DataNotExist.dbf',"DoesExist = '0'")

This adds a field 'DoesExist' to your dbf table then iterates the table recording if the dataset is found in the full path and finally extracts a table for just the files that don't exist. Beware though a 2nd iteration will fail at the add field stage as the field already exists.

Another viable option is using a python dictionary, which stores value pairs, in this case (fullPath,Exists) using the full path for the dataset as the key and exists/not exists as the value:

import arcpy

arcpy.env.workspace = r"C:\TestFolder"

#dbf table used for processing
dbf = "ProcessControlTable.dbf" # you don't need the full path because it's in the current workspace
#Column within dbf table containing file paths 
myColumn   = "FI_PATH"
ExistsDict = {}

with arcpy.da.SearchCursor(dbf,myColumn) as sCur:
    for sRow in sCur:
        if arcpy.Exists(sRow[0]):
            ExistsDict[sRow[0]]='1'
        else:
            ExistsDict[sRow[0]]='0'

for FC in ExistsDict: # loop through each dataset path and print if exists
    print '{} exists value {}'.format(ExistsDict[FC])
Source Link
Michael Stimson
  • 25.7k
  • 2
  • 35
  • 75

Perhaps something like this might serve your eventual purpose:

import arcpy

arcpy.env.workspace = r"C:\TestFolder"

#dbf table used for processing
dbf = "ProcessControlTable.dbf" # you don't need the full path because it's in the current workspace
#Column within dbf table containing file paths 
myColumn = "FI_PATH"

arcpy.AddField_management(dbf,'DoesExist','STRING')
with arcpy.da.UpdateCursor(dbf,[myColumn,'DoesExist']) as uCur:
    for uRow in uCur:
        if arcpy.Exists(uRow[0]):
            uRow[1]='1'
        else:
            uRow[1]='0'
        uCur.updateRow(uRow)

# select the non-existing into a new table
arcpy.TableSelect_analysis(dbf,'DataNotExist.dbf',"DoesExist = '0'")

This adds a field 'DoesExist' to your dbf table then iterates the table recording if the dataset is found in the full path and finally extracts a table for just the files that don't exist. Beware though a 2nd iteration will fail at the add field stage as the field already exists.