Field mapping 10.3.1

784
5
09-27-2016 01:53 PM
PacoAlverez
New Contributor III

 i upgraded from 10.2.2 to 10.3.1 and now my script does not run properly. It runs all they way and doesn't give an error.

The join runs fin and it creates the feature class but when i check feature class "NotifiLotsTest" all the fields are Null.

It ran fine in 10.2.2 so i am not sure what's going on with it now, something to do with the field mapping???.. help please i am lost it's a simple script but i can't figure out what's going on....

arcpy.env.qualifiedFieldNames = False
arcpy.env.overwriteOutput = True

Taxparcels = r"Database Connections\Taxparcels"
Table = r"Database Connections\Table"

fc = "C:/Temp/Test.gdb/NotifLotsTest"

#Delete feature class if it exists
if arcpy.Exists(fc):
   arcpy.Delete_management(fc)

fc1 = "C:/Temp/Test.gdb/NotifTest"

#Delete feature class if it exists
if arcpy.Exists(fc1):
   arcpy.Delete_management(fc1)   

# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(Taxparcels, "In_memory\TaxPar")

# Process: Add Join
arcpy.AddJoin_management("In_memory\TaxPar", "ACCOUNT", Table, "Acct")

#check to make sure Joined Feature class is being generated
arcpy.FeatureClassToFeatureClass_conversion("In_memory\TaxPar","C:/Temp/Test.gdb/", "NotifTest")

TaxPar1 = "In_memory\TaxPar"
#arcpy.MakeFeatureLayer_management("C:/Temp/Test.gdb//NotifTest",TaxPar1)

#Field Mapping
def Layers0(TaxPar1):
    FieldMapString = "" \
                + """DXF_TEXT "DXF_TEXT" true true false 20 Text 0 0 ,First,#,""" + TaxPar1 + """,DXF_TEXT,-1,-1;"""\
                + """ACCOUNT "ACCOUNT" true true false 11 Text 0 0 ,First,#,""" + TaxPar1 + """,ACCOUNT,-1,-1;"""\
                + """OwnerName "OwnerName" true true false 100 Text 0 0 ,First,#,""" + TaxPar1 + """,OwnerName,-1,-1;"""\
                + """Address "Address" true true false 64 Text 0 0 ,First,#,""" + TaxPar1 + """,Address,-1,-1;"""\
                + """City "City" true true false 32 Text 0 0 ,First,#,""" + TaxPar1 + """,City,-1,-1;"""\
                + """State "State" true true false 4 Text 0 0 ,First,#,""" + TaxPar1 + """,State,-1,-1;"""\
                + """ZipCode "ZipCode" true true false 10 Text 0 0 ,First,#,""" + TaxPar1 + """,ZipCode,-1,-1;"""\

    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.FeatureClassToFeatureClass_conversion(TaxPar1, "C:/Temp/Test.gdb/", "NotifLotsTest", "", Layers0(TaxPar1),"")


0 Kudos
5 Replies
DanPatterson_Retired
MVP Esteemed Contributor

quick question... this ... FieldMapString = "" \  ...is that supposed to be... FieldMapString = """ \

0 Kudos
PacoAlverez
New Contributor III

I have double quotations.

0 Kudos
PacoAlverez
New Contributor III

If i add more than two quotations marks i get invalid Syntax. Did something change for filed mapping in 10.3.1?

I am confused as to why this simple script doesn't run.

0 Kudos
DarrenWiens2
MVP Honored Contributor

Not sure if this is the issue, but can you try it with raw notation strings? I'm sure I've had issues not using raw notation with the in_memory workspace. And, '\T' is pretty close to '\t' (tab).

r"in_memory\TaxPar"
vs.
"In_memory\TaxPar"
0 Kudos
PacoAlverez
New Contributor III

what i found was i had to include line 29, make feature layer from the feature class that was created after the join. I guess i can't use in_memory in the field mapping...?  I swear it worked in 10.2.2

0 Kudos