samedi 28 février 2015

How to set NULL value by arcpy.da.InsertCursor on date column?


How to set NULL value by arcpy.da.InsertCursor on date column?


I try insert "NULL", None, '', 0



dictIN= [{'field1':"test1",'date1':'01-02-2015','date1':''},\
{'field1':"test2",'date1':'01-02-2015','date1':'01-02-2015'},\
{'field1':"test3",'date1':'','date1':''},\
{'field1':"test4",'date1':'01-02-2015','date1':''}]


def setNULLIf(field):
if field == '':
return None #try NULL,'',0
else: return field

cursor = arcpy.da.InsertCursor(GDB,("field1", "date1", "date2"))
for x in dictIN:
cursor.insertRow((x[field1'], setNULLIf(x['date1']), setNULLIf(x['date2'])))


Is it possible by arcpy.da ? I use ArcGIS 10.2. I try insert data to GDB file.





Aucun commentaire:

Enregistrer un commentaire