Change Field Type using Field Mapping for List of Tables using Python

المشرف العام

Administrator
طاقم الإدارة
I have a collection of about 200 tables, and I would like to make sure that all the fields are text before merging them into a single table using python. There is at least one field ("Number_of") which I know for sure is integer. All the tables have the exact same schema.

This Geonet thread has been really helpful, but I still can't get it.

Here is my code:

fieldList = ['Feature','Number_of','Water_Type','GlobalID']fieldMappings = arcpy.FieldMappings()for field in fieldList: vars()[field] = arcpy.FieldMap() outField = vars()[field].outputField vars()[field].type = "Text" vars()[field].outputField = outField fieldMappings.addFieldMap([field])This current code returns an error saying, "NameError: The attribute 'outputField' is not supported on this instance of FieldMap."

Essentially, all I need to do is create a Field Map that I can use in the python Merge tool which will convert the "Number_of" field to text.



أكثر...
 
أعلى