Select to view content in your preferred language

Calculate Value Python dbf table

2404
2
06-21-2011 05:49 AM
Florianflo
Emerging Contributor
HI

i will get a value from a table dbf.
for this i use the Calulate Value Tool in ArcGis 9.3

I wrote this small pyton tool but it will not work, could somebody help me

Minimum("D:/data/program/test3_copy.dbf", "N15","10")

def Minimum(inputData, FieldName,row):
    import arcgisscripting
    gp = arcgisscripting.create()
    gpResult = gp.GetCellValue(inputData, FieldName,row)
    print gp.AddMessage( str( gpResult.GetOutput(0) ))
Tags (2)
0 Kudos
2 Replies
AnthonyFarndon
Frequent Contributor
getCellValue is for retrieving raster pixels, to read values from a .dbf table you will need to use a searchcursor
0 Kudos
Florianflo
Emerging Contributor
i try this with a search courser but it will no work too

def Minimum(inputData, FieldName,row):

    import arcgisscripting
    gp = arcgisscripting.create(9.3)

   inputData = "D:\Data\Test.dbf"
FieldName = "N15"
intable = inputData
infield = FieldName

# open cursor
rows = gp.searchcursor(intable)
row = rows.next()
fval = row.GetValue(infield)
gp.SetParameterAsText(2, str(fval))




and how can i define the row i want?

a other problem in this code is that i get a massage:

ERROR 000539: Runtime error <type 'exceptions.NameError'>: name 'gp' is not defined
Failed to execute (Calculate Value).

but i think i defined gp with this gp = arcgisscripting.create()
0 Kudos