I am using arcpro3.0.3 and am using the TableToTable API to convert a shapefile .dbf file into .csv.
One of the arguments to TableToTable is a FieldMappings parameters, and I amusing this to rename all of the fields in the original shapefile.
The documentation of FieldMap has example code which looks like this (names of variables not the same as in documentation, but you get the idea)
fm = arcpy.FieldMap()
fm.addInputField(tablename,oldfieldname)
outf = fm.outputField
outf.name = newfieldname
fm.outputField = out
...
The above code seems to work, but this code below (which appears to me to have the same effect does not)
The code which differs in the two examples is in red
fm = arcpy.FieldMap()
fm.addInputField(tablename,oldfieldname)
fm.outputField.name = newfieldname
...
In the first case the field in question has its name in the output .csv file changed (from oldfieldname to newfieldname; in the second case the field name remains unchanged. Why is that? To my eye both code snippets do exactly the same thing.