laptop and a wrench

Bogue

The arcpy.FieldMap or arcpy.FieldMappings object, or both fail to handle a date field in ArcGIS Pro 3.x. Dates are not populated in the appropriate field.

ArcGIS Pro
Numéro d’ID de bogue BUG-000161939
EnvoiOctober 6, 2023
Dernière modificationJune 5, 2024
S’applique àArcGIS Pro
Version trouvée3.1
Système d’exploitationWindows OS
Version du système d’exploitation10.0
StatutDuplicate

Solution de contournement

The best practice for using the arcpy.FieldMapping() and arcpy.FieldMappings() objects is to construct the field mapping by adding the target and input dataset fields using addTable first. The following code snippet produced the expected output for the provided script:

... 
try:
    ## Truncate the staging table
    ap.TruncateTable_management(tblCntyDataStaging)
    ## Run the arcpy fieldmapper to map field name changes between the two schemas
    fms = arcpy.FieldMappings()
    
    ### Use addTable for target and input per best practices
    fms.addTable(tblCntyDataStaging)
    fms.addTable(tblCntyDataSource)
    ###
    for field in fieldList_cds:
        if field.name != "OBJECTID":
            fm = arcpy.FieldMap()
            fm.addInputField(tblCntyDataSource, field.name)
            f_out = fm.outputField
            f_out.name = fieldMapDict_cd[field.name]
            f_out.type = field.type
            fm.outputField = f_out
            fms.addFieldMap(fm)
    # Populate the fresh table into the staging table
    arcpy.Append_management(
         tblCntyDataSource, tblCntyDataStaging, "NO_TEST", field_mapping=fms
     )
...

Étapes pour reproduire

ID de bogue: BUG-000161939

Logiciel:

  • ArcGIS Pro

Recevoir une notification lorsque le statut d’un bogue change

Télécharger l’application Esri Support

En savoir plus sur ce sujet

Obtenir de l’aide auprès des experts ArcGIS

Contacter le support technique

Télécharger l’application Esri Support

Accéder aux options de téléchargement