I have a pivot table that has 11 ShipTypeGroup fields with "Long" field properties that can't be divided by 12, due to decimal places. Therefore I am trying to create a new field, copy attributes across from each ShipTypeGroup and recalculate. Each ShipTypeGroup must be recalculated into a field that has the same ShipTypeGroup. So for example, adding a column called Ave_STG_1 and then calculating the figures from ShipTypeGroup1 field and so on for all 10 types. However when it throws up an error or doesn't calculate the correct fields properly. I'm not sure if I have passed the newly created field into the "Calculate Field" part of the script properly, or do I add an if/else statement.
import arcpy
pt = r"C:\AIS\Density_Grid_test.gdb\PivotTable"
flist = arcpy.ListFields(pt, "*ShipTypeGroup*")
for f in flist:
arcpy.AddField_management(pt, f.name.replace("ShipTypeGroup","Ave_STG"),"DOUBLE")
newflist = arcpy.ListFields(pt, "*Ave_STG*")
for nf in newflist:
arcpy.CalculateField_management(pt, nf.name, "!{}!/12".format(f.name), "PYTHON_9.3")
print f.name + " changed into " + nf.name + " and recalculated"