fieldTypeDictionary = {'SmallInteger': 'SHORT', 'Integer': 'LONG', 'Single': 'FLOAT', 'Double': 'DOUBLE', 'String': 'TEXT', 'Date': 'DATE'} fldType = searchTheField.field_type arcpy.AddField_management(updateDSParam,updateFieldParam,fieldTypeDictionary[fldType], fldPrecision, fldScale, fldLength)
I have also run into this issue. At first I set up a complex set of if/else statements to handle this but then someone recommended using a simple python dictionary to convert the reported type to the desired type.fieldTypeDictionary = {'SmallInteger': 'SHORT', 'Integer': 'LONG', 'Single': 'FLOAT', 'Double': 'DOUBLE', 'String': 'TEXT', 'Date': 'DATE'} fldType = searchTheField.field_type arcpy.AddField_management(updateDSParam,updateFieldParam,fieldTypeDictionary[fldType], fldPrecision, fldScale, fldLength)I hope this helps, good luck.Joel
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.