Select to view content in your preferred language

Python - Append Field mapping

1816
1
Jump to solution
06-19-2012 10:19 AM
Pierre-LucBoivin
Frequent Contributor
Hi,

I'm trying to populate a DBase table from 2 tables with the Append_management tools. My script works fine but I would like to replace the absolute path in the field mapping with the 2 variables name and that doesn't work.

Working script
    

SitAct = r'C:\Temp\Deccan\SitRZValues.dbf'

ScePro = r'C:\Temp\Deccan\Sce_RZValues.dbf'

arcpy.Append_management("C:\\Temp\\Deccan\\Sce_RZValues.dbf;C:\\Temp\\Deccan\\SitRZValues.dbf", resultat, "NO_TEST", "RESPZONE \"RESPZONE\" true false false 20 Text 0 0 ,First,#,C:\\Temp\\Deccan\\Sce_RZValues.dbf,RESPZONE,-1,-1,C:\\Temp\\Deccan\\SitRZValues.dbf,RESPZONE,-1,-1;SITGA4 \"SITGA4\" true false false 20 Text 0 0 ,First,#,C:\\Temp\\Deccan\\SitRZValues.dbf,GA4,-1,-1;SITGA12 \"SITGA12\" true false false 20 Text 0 0 ,First,#,C:\\Temp\\Deccan\\SitRZValues.dbf,GA12,-1,-1;SITPPBRUT \"SITPPBRUT\" true false false 19 Double 0 19 ,First,#,C:\\Temp\\Deccan\\SitRZValues.dbf,SitPPBRUT,-1,-1;SITFFBRUT \"SITFFBRUT\" true false false 19 Double 0 19 ,First,#,C:\\Temp\\Deccan\\SitRZValues.dbf,SitFFBRUT,-1,-1;SITPP_TEMP \"SITPP_TEMP\" true false false 20 Text 0 0 ,First,#,C:\\Temp\\Deccan\\SitRZValues.dbf,SitPPTEMPS,-1,-1;SITFF_TEMP \"SITFF_TEMP\" true false false 20 Text 0 0 ,First,#,C:\\Temp\\Deccan\\SitRZValues.dbf,SitFFTEMPS,-1,-1;SCEGA4 \"SCEGA4\" true false false 20 Text 0 0 ,First,#,C:\\Temp\\Deccan\\Sce_RZValues.dbf,GA4,-1,-1;SCEGA12 \"SCEGA12\" true false false 20 Text 0 0 ,First,#,C:\\Temp\\Deccan\\Sce_RZValues.dbf,GA12,-1,-1;SCEPPBRUT \"SCEPPBRUT\" true false false 19 Double 0 19 ,First,#,C:\\Temp\\Deccan\\Sce_RZValues.dbf,ScePPBRUT,-1,-1;SCEFFBRUT \"SCEFFBRUT\" true false false 19 Double 0 19 ,First,#,C:\\Temp\\Deccan\\Sce_RZValues.dbf,SceFFBRUT,-1,-1;SCEPP_TEMP \"SCEPP_TEMP\" true false false 20 Text 0 0 ,First,#,C:\\Temp\\Deccan\\Sce_RZValues.dbf,ScePPTEMPS,-1,-1;SCEFF_TEMP \"SCEFF_TEMP\" true false false 20 Text 0 0 ,First,#,C:\\Temp\\Deccan\\Sce_RZValues.dbf,SceFFTEMPS,-1,-1", "")


Problematic script
As you see, I replace in red all the path with the variable name

SitAct = r'C:\Temp\Deccan\SitRZValues.dbf'

ScePro = r'C:\Temp\Deccan\Sce_RZValues.dbf'

    arcpy.Append_management([ScePro,SitAct], resultat, "NO_TEST", "RESPZONE \"RESPZONE\" true false false 20 Text 0 0 ,First,#,ScePro,RESPZONE,-1,-1,SitAct,RESPZONE,-1,-1;SITGA4 \"SITGA4\" true false false 20 Text 0 0 ,First,#,SitAct,GA4,-1,-1;SITGA12 \"SITGA12\" true false false 20 Text 0 0 ,First,#,SitAct,GA12,-1,-1;SITPPBRUT \"SITPPBRUT\" true false false 19 Double 0 19 ,First,#,SitAct,SitPPBRUT,-1,-1;SITFFBRUT \"SITFFBRUT\" true false false 19 Double 0 19 ,First,#,SitAct,SitFFBRUT,-1,-1;SITPP_TEMP \"SITPP_TEMP\" true false false 20 Text 0 0 ,First,#,SitAct,SitPPTEMPS,-1,-1;SITFF_TEMP \"SITFF_TEMP\" true false false 20 Text 0 0 ,First,#,SitAct,SitFFTEMPS,-1,-1;SCEGA4 \"SCEGA4\" true false false 20 Text 0 0 ,First,#,ScePro,GA4,-1,-1;SCEGA12 \"SCEGA12\" true false false 20 Text 0 0 ,First,#,ScePro,GA12,-1,-1;SCEPPBRUT \"SCEPPBRUT\" true false false 19 Double 0 19 ,First,#,ScePro,ScePPBRUT,-1,-1;SCEFFBRUT \"SCEFFBRUT\" true false false 19 Double 0 19 ,First,#,ScePro,SceFFBRUT,-1,-1;SCEPP_TEMP \"SCEPP_TEMP\" true false false 20 Text 0 0 ,First,#,ScePro,ScePPTEMPS,-1,-1;SCEFF_TEMP \"SCEFF_TEMP\" true false false 20 Text 0 0 ,First,#,ScePro,SceFFTEMPS,-1,-1", "")



Thanks you for you help

Pierre-Luc
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Pierre-LucBoivin
Frequent Contributor
Nevermind,

I found a way to make it's work using " + SitAct + "


arcpy.Append_management([SitAct],[ScePro], resultat, "NO_TEST", "RESPZONE \"RESPZONE\" true false false 20 Text 0 0 ,First,#," + ScePro + ",RESPZONE,-1,-1," + SitAct + ",RESPZONE,-1,-1;SITGA4 \"SITGA4\" true false false 20 Text 0 0 ,First,#," + SitAct + ",GA4,-1,-1;SITGA12 \"SITGA12\" true false false 20 Text 0 0 ,First,#," + SitAct + ",GA12,-1,-1;SITPPBRUT \"SITPPBRUT\" true false false 19 Double 0 19 ,First,#," + SitAct + ",SitPPBRUT,-1,-1;SITFFBRUT \"SITFFBRUT\" true false false 19 Double 0 19 ,First,#," + SitAct + ",SitFFBRUT,-1,-1;SITPP_TEMP \"SITPP_TEMP\" true false false 20 Text 0 0 ,First,#," + SitAct + ",SitPPTEMPS,-1,-1;SITFF_TEMP \"SITFF_TEMP\" true false false 20 Text 0 0 ,First,#," + SitAct + ",SitFFTEMPS,-1,-1;SCEGA4 \"SCEGA4\" true false false 20 Text 0 0 ,First,#," + ScePro + " ,GA4,-1,-1;SCEGA12 \"SCEGA12\" true false false 20 Text 0 0 ,First,#," + ScePro + " ,GA12,-1,-1;SCEPPBRUT \"SCEPPBRUT\" true false false 19 Double 0 19 ,First,#," + ScePro + " ,ScePPBRUT,-1,-1;SCEFFBRUT \"SCEFFBRUT\" true false false 19 Double 0 19 ,First,#," + ScePro + " ,SceFFBRUT,-1,-1;SCEPP_TEMP \"SCEPP_TEMP\" true false false 20 Text 0 0 ,First,#," + ScePro + " ,ScePPTEMPS,-1,-1;SCEFF_TEMP \"SCEFF_TEMP\" true false false 20 Text 0 0 ,First,#," + ScePro + " ,SceFFTEMPS,-1,-1", "")

View solution in original post

0 Kudos
1 Reply
Pierre-LucBoivin
Frequent Contributor
Nevermind,

I found a way to make it's work using " + SitAct + "


arcpy.Append_management([SitAct],[ScePro], resultat, "NO_TEST", "RESPZONE \"RESPZONE\" true false false 20 Text 0 0 ,First,#," + ScePro + ",RESPZONE,-1,-1," + SitAct + ",RESPZONE,-1,-1;SITGA4 \"SITGA4\" true false false 20 Text 0 0 ,First,#," + SitAct + ",GA4,-1,-1;SITGA12 \"SITGA12\" true false false 20 Text 0 0 ,First,#," + SitAct + ",GA12,-1,-1;SITPPBRUT \"SITPPBRUT\" true false false 19 Double 0 19 ,First,#," + SitAct + ",SitPPBRUT,-1,-1;SITFFBRUT \"SITFFBRUT\" true false false 19 Double 0 19 ,First,#," + SitAct + ",SitFFBRUT,-1,-1;SITPP_TEMP \"SITPP_TEMP\" true false false 20 Text 0 0 ,First,#," + SitAct + ",SitPPTEMPS,-1,-1;SITFF_TEMP \"SITFF_TEMP\" true false false 20 Text 0 0 ,First,#," + SitAct + ",SitFFTEMPS,-1,-1;SCEGA4 \"SCEGA4\" true false false 20 Text 0 0 ,First,#," + ScePro + " ,GA4,-1,-1;SCEGA12 \"SCEGA12\" true false false 20 Text 0 0 ,First,#," + ScePro + " ,GA12,-1,-1;SCEPPBRUT \"SCEPPBRUT\" true false false 19 Double 0 19 ,First,#," + ScePro + " ,ScePPBRUT,-1,-1;SCEFFBRUT \"SCEFFBRUT\" true false false 19 Double 0 19 ,First,#," + ScePro + " ,SceFFBRUT,-1,-1;SCEPP_TEMP \"SCEPP_TEMP\" true false false 20 Text 0 0 ,First,#," + ScePro + " ,ScePPTEMPS,-1,-1;SCEFF_TEMP \"SCEFF_TEMP\" true false false 20 Text 0 0 ,First,#," + ScePro + " ,SceFFTEMPS,-1,-1", "")
0 Kudos