I'm trying to create a task that configures multiple different fields starting from an excel sheet within ArcGIS Pro. An issue I'm facing, and wondering if anyone else has experienced, is related to when I load fields/import field mapping (not to be confused with the Field Maps application). One of the first steps I'd like to have completed within my task would require a user to import an excel sheet that will then have very specific field types and lengths configured through an Export Table conversion tool (as the default text length for an imported excel sheet is 8000 characters -- way too large for my already large dataset). I've found that when the excel .csv table's name is different from the initial field map export, i can never import my '.fieldmap', and have to manually set the field mapping properties each time I run my task.
Is this a bug, or is there a work-around for importing the fieldmapping of my to-be feature layer? Has anyone else had this issue before?
I'm considering having my task create duplicates of all my fields, having a step calculate the new field based off the old field, and then deleting the old fields, but this would result in my new fields being named something that could break an application this data is displayed within due to the fields not matching.....
Solved! Go to Solution.
It’s expected behavior (not a bug): a saved .fieldmap from Export Table is tied to the specific input dataset/layer it was exported from. If the input table is different (including a different name/source), ArcGIS Pro will reset the Field Map when you try to load it:
Use the Load option to load a .fieldmap file. The feature layer or dataset specified in the file must match the dataset used in the tool. Otherwise, the Field Map parameter will be reset. - Export Table (Conversion Tools) | ArcGIS Pro documentation
Workarounds to use in a Task
1) Make the input dataset identity match. In the Task, add a step that ensures the incoming CSV/XLSX is brought in with the same table name as your template (for example, copy/rename it into a file geodatabase table with a fixed name), then run Export Table and load the .fieldmap.
2) Define the CSV field types/lengths before importing. For CSV specifically, use schema.ini to control types/lengths up front, then you won’t be fighting the 8000-length default. Esri documents schema.ini as the supported workaround for controlling how CSV fields are interpreted BUG-000174571 for ArcGIS Pro
3) Use Python (FieldMappings) instead of loading a .fieldmap. If you need the Task to work regardless of the input table name, the robust option is a script tool that builds `FieldMappings/FieldMap` dynamically against whatever input is provided. Mapping input fields to output fields | ArcGIS Pro documentation
It’s expected behavior (not a bug): a saved .fieldmap from Export Table is tied to the specific input dataset/layer it was exported from. If the input table is different (including a different name/source), ArcGIS Pro will reset the Field Map when you try to load it:
Use the Load option to load a .fieldmap file. The feature layer or dataset specified in the file must match the dataset used in the tool. Otherwise, the Field Map parameter will be reset. - Export Table (Conversion Tools) | ArcGIS Pro documentation
Workarounds to use in a Task
1) Make the input dataset identity match. In the Task, add a step that ensures the incoming CSV/XLSX is brought in with the same table name as your template (for example, copy/rename it into a file geodatabase table with a fixed name), then run Export Table and load the .fieldmap.
2) Define the CSV field types/lengths before importing. For CSV specifically, use schema.ini to control types/lengths up front, then you won’t be fighting the 8000-length default. Esri documents schema.ini as the supported workaround for controlling how CSV fields are interpreted BUG-000174571 for ArcGIS Pro
3) Use Python (FieldMappings) instead of loading a .fieldmap. If you need the Task to work regardless of the input table name, the robust option is a script tool that builds `FieldMappings/FieldMap` dynamically against whatever input is provided. Mapping input fields to output fields | ArcGIS Pro documentation
This is awesome, thank you!