when I run the script below in arcmap in the python window the date gets print however I get the following error:Parsing error SyntaxError: invalid syntax (line 19) the date isn't showing as text in textelement"survey"

what am i missing here?

from datetime import date,datetime,time
from xlrd import open_workbook,xldate_as_tuple
from arcpy import mapping 

book = open_workbook(r"C:\Users\robert\Downloads\Hyrografie_2014_projectenlijst.xls")#excelfile

sheet = book.sheet_by_index(0)#eerste(0)blad

x =  int(arcpy.GetParameterAsText(0) ) #rij 3(0,1,2)!
survey = xldate_as_tuple(sheet.cell(x,6).value,book.datemode)#laatste opname

print date(*survey[:3])

mxd = mapping.MapDocument("current") 
ellist = arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT") 

for el in ellist:
 if el.name == "survey":
  el.text = survey#line19

1 Answer 1


The text property from the TextElement (arcpy.mapping) is expecting a string and the survey variable is a tuple. Try using str() to convert the datatype.

for el in ellist:
    if el.name == "survey":
        el.text = str(survey)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.