AnsweredAssumed Answered

Using PyWin to take the first 11 characters from a field and apend ".pdf" to the end in a new field

Question asked by bagardne on Oct 23, 2014
Latest reply on Oct 23, 2014 by curtvprice

I have two fields: "Report_Number" and "Hyperlink." I want to take the first 11 characters from Report_Number and add them to Hyperlink while apending ".pdf" to the end. The result would be similar to: Report_Number = 20120328021; Hyperlink = 20120328021.pdf

So far, I have:

import arcpy
field = 'Report_Number'
field2 = 'Hyperlink'
cursor = arcpy.UpdateCursor("CrashReport")
for row in cursor:
row.setValue(field2, field[:11]) + '.pdf')
cursor.updateRow(row)

 

I am getting an error:

Runtime error

Traceback (most recent call last):

  File "<string>", line 2, in <module>

  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects\arcobjects.py", line 1044, in getValue

    return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args)))

RuntimeError: ERROR 999999: Error executing function.

 

PLEASE HELP!

Outcomes