I am fairly new to python. I'm trying to set this function into a variable, but i can't seem to get it to work.
Can you take a look at my script?
import arcpy
arcpy.env.workspace = "M:\Parks\HQ\OPERATIONS\CPI\Asset_Management\GNSS Projects\Parks Inventory\MergedParks\Ram_Falls_PP\CW_Ram_Falls_PP\CW_Ram_Fall_PP.gdb"
a2 = """def rep_field(in_fld, rep_value):
targets = ['W:\OPERATIONS\CPI\Asset_Management\GNSS Projects\Parks Inventory\Ram Falls PP\RAM FALLS PP JULY 28 2015 JR~files','W:\OPERATIONS\CPI\Asset_Management\GNSS Projects\Parks Inventory\Ram Falls PP\RAMFALLSPP_JULY28_2015_JL~files']
for targ in targets:
in_fld = in_fld.replace(targ, rep_value)
return in_fld"""
a1 = """rep_field (!Picture!,'\\\env.gov.ab.ca\Parks\CityWorks\Referenced\Ram_Falls_PP')"""
a11 = """rep_field (!Picture1!,'\\\env.gov.ab.ca\Parks\CityWorks\Referenced\Ram_Falls_PP')"""
arcpy.CalculateField_management(in_table="Bench_and_Table", field="Picture", expression = a1, expression_type="PYTHON_9.3", code_block = a2)
arcpy.CalculateField_management(in_table="Bridge", field="Picture1", expression = a11, expression_type="PYTHON_9.3", code_block = a2)
It is now giving me a
ERROR 000989: Python syntax error: Parsing error IndentationError: unindent does not match any outer indentation level (line 3) Failed to execute (CalculateField).
code
formatting button ({}
), and to include the exact error, in context (you can use "Quote" for the error). I personally detest integrated development environments, but using one would likely show you your error.