I had a hard time understanding field mapping until someone posted a code.
I use the code below and works great.
import arcpy,sys
from datetime import datetime as d
startTime = d.now()
start_time = time.time()
PT1 = "C:/Temp/Scratchworkspace.gdb/Drain"
FieldMapString = '''
DXF_TEXT "DXF_TEXT" true true false 11 Text 0 0 ,First,#, {0}, DXF_TEXT,-1,-1;
ACCOUNT "ACCOUNT" true true false 11 Text 0 0 ,First,#, {0}, ACCOUNT,-1,-1;
PIN "PIN" true true false 13 Text 0 0 ,First,#, {0}, PIN,-1,-1;
ACRES "ACRES" true true false 4 Double 0 0 ,First,#, {0}, ACRES,-1,-1;
Instrument "Instrument" true true false 10 Text 0 0 ,First,#, {0}, Instrument,-1,-1;
SiteAddres "SiteAddres" true true false 106 Text 0 0 ,First,#, {0}, SiteAddres,-1,-1;
SiteCity "SiteCity" true true false 32 Text 0 0 ,First,#, {0}, SiteZip,-1,-1;
SiteZip "SiteZip" true true false 10 Text 0 0 ,First,#, {0}, SiteZip,-1,-1
'''
def Layers1(PT1):
"""pass the variable and the constant into
the function
"""
fieldmappings = arcpy.FieldMappings()
fieldmappings.loadFromString(FieldMapString)
return fieldmappings
def main(args=None):
if args is None:
args = sys.argv
# Process: Feature Class to Feature Class
arcpy.Append_management(PT1, "C:\Temp\Scratchworkspace.gdb\PT_ALL","NO_TEST", Layers1(PT1))
try:
print ('(Elapsed time: ' + str(d.now() - startTime)[:-3] + ')')
except Exception as e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print ("Line %i" % tb.tb_lineno)
print (e.message)