Preventing text from becoming Date type field using arcpy.conversion.TableToTable

177
0
07-04-2021 08:19 PM
ToyotaT18
New Contributor III

Hi, I'm trying to prevent ArcGIS Pro from converting text (dates) to a Date type field when running arcpy.conversion.TableToTable(). The 'from' table is a csv file.

I've tried creating a FieldMappings from the csv table, and changing the relevant FieldMap outputField type, however when I apply this using replaceFieldMap the output table ends up blank (although it does apply the field as text instead of date).

My code is something like:

fms = arcpy.FieldMappings()
fms.addTable(csv_file)

fm = fms.getFieldMap(fms.findFieldMapIndex("date_field"))
fname = fm.outputField
fname.type = "String"
fm.outputField = fname
fms.replaceFieldMap(fms.findFieldMapIndex("date_field"), fm)

arcpy.conversion.TableToTable(csv_file, aprxgdb, 'out_table', '', fms)

0 Kudos
0 Replies