So I have a feature class in a GDB that contains time data that I wish to carry out calculations through arcpy. This data was entered from a string to a datetime format into the featureclass through a script that handles a special type of ASCII file.
The output format of this tuple, when accessed using arcpy.da.SearchCursor() takes the form of the following:
(datetime.datetime(1899, 12, 30, 13, 59, 18),)
Where the type of value I need to carry out further calculation needs to take the following form:
datetime.datetime(1899, 12, 30, 0, 0)
I get to this problem when I try the following code:
fc = "C:\\scripting\\timetest.gdb\\test1\\"
rows = arcpy.da.SearchCursor(fc,["time"])
a = []
for row in rows:
a.append(row)
And when I look at the type of the output, I receive a 'tuple', which is the normal data output of the arcpy.da.SearchCursor() class.
type(a[0])
<type 'tuple'>
But what I really want to do is break the information out of the tuple so that I can carry out normal python operations with the datetime.datetime objects.
The help pages haven't been terribly useful in finding a way to break the data out of the tuple format. I can't print the information inside the tuple, nor can I access like an array. What I seek to do is get at the datetime.datetime object inside the tuple so that I may carry out my analysis. Has anyone run into this problem before?
I've uploaded a shapefile with the problem that I'm running at http://brianbancroft.ca/docs/timetest.zip in case someone wants to try running it.