Arcpy FieldMappings documentation includes the path to the input table which can be seen in the following string representation as c:\\data\\fgdb.gdb\\south_america:
fieldmappings_string = 'REGION "Region" true true false 21 Text -1 -1,First,#,c:\\data\\fgdb.gdb\\north_america,REGION,-1,-1,c:\\data\\fgdb.gdb\\south_america,REGION2,-1,-1'
In the case of arcpy ExportFeatures both in_features and field_mappings will include path to input table.
arcpy.conversion.ExportFeatures(in_features, out_features,
{where_clause}, {use_field_alias_as_name}, {field_mapping}, {sort_field})
This makes me wonder a few things. What if the input tables between 'in_features' and 'field_mapping' did not match? If they must match, then why doesn't fieldmappings inherit the input path from in_features?
Thank you,
Tyler
The input needs to match or you will get an error that says it cant find the field in the featureclass specified. Think about it though, if you try to use a field from another featureclass, how would it know which value goes to what feature? What if there are more or less values from that other featureclass?
It does inherit the path if you do not set the optional field mapping parameter. If you want to drop/rename fields, you'll need to use the field_mapping parameter.
----------
Right below that example, which is for a merge (so there are two inputs), there is a key that could shed some light into this. Lets split this string up to match the help.
The first nine values in the string define an output field and are space delimited.
'REGION "Region" true true false 21 Text -1 -1,
The remaining values define the field map characteristics and are comma delimited.
First,#,c:\\data\\fgdb.gdb\\north_america,REGION,-1,-1,c:\\data\\fgdb.gdb\\south_america,REGION2,-1,-1'
Any number of input fields can be mapped to the output field, not only two, as implied in the example. Include the merge rule and concatenator once, and include the dataset path, field name, and start position and end position for each input field.
You can see how confusing the string representation can get and I have yet to come into a need to code it that way. I added the emphasis because its a bit hidden in the docs but is key here. Hope this helps.