AnsweredAssumed Answered

Python script Update Cursor

Question asked by jameljoseph on Nov 20, 2015
Latest reply on Nov 20, 2015 by jameljoseph

I have a table in my geodatabase that contains fields with some values and empty fields. 

 

What I am trying to do is first let the user select the table to use, then add values to 2 fields based on values in another field but I am a beginner with python so I was wondering if someone here knows what is wrong with my script.

 

Thank you

 

 

import arcpy

 

# Get table parameter

param1 = arcpy.Parameter(

    displayname="Roads")

   

# Open table to edit

GeoDBLocation = open (param1, 'r+')

Fields["LABEL", "SYMBOL", "SYM_TYPE"]

 

# Add data

cur = arcpy.UpdateCursor(GeoDBLocation)

For row in cur:

    If row.getvalue("LABEL") == "H":

        row.setvalue("SYMBOL", "3.01")

        row.setvalue("SYM_TYPE", "S")

    Elif row.getvalue("LABEL") == "L":

        row.setvalue("SYMBOL", "3.02")

        row.setvalue("SYM_TYPE", "F")

    Else:

        row.setvalue("SYMBOL", "0.01")

        row.setvalue("SYM_TYPE", "O")

    cursor.updateRow(row)

       

 

#Delete cursor

del row

del cur

   

#close file

GeoDBLocation.close

Outcomes