I need to write the output of a search cursor to a csv file. I stole an idea from this Stackexchange post that uses list comprehension and it works great. The problem is one of my fields is a date field, and it's goofing up the works.
import arcpy
fc = r'\Path\to\my\featureclass'
fields = ['UNIQUE_ID','asset_id','Condition','Year_Installed','Carto_ID',
'Pave_Area','Pave_Width','Length','AM_Asset_ID','Lanes','OCI_Date']
lines = [row for row in arcpy.da.SearchCursor(fc,fields)]Here is what one of the tuples in the lines list looks like:
('10100922','PWOPS_pave00024318',84,1989,7366264,8800.60992698,35.0,
251.44599791,None,None, datetime.datetime(2019, 2, 1, 0, 0))Notice how the field OCI_date comes from the search cursor. I get what it's doing with the datetime.datetime() method, but how can I avoid that? I guess I could just append every row to the list as individual tuple elements and for the date, format in a fashion that works, but maybe there is a better way?