<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Field Mapping Help With Merge Tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149413#M11579</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you are only editing the existing field map and dont delete them from the field map they will be transfered to your new feature class. You can create a new field map and only add the fields you want to that object though.&lt;STRONG&gt; I do not really like the field mapping functions very much&lt;/STRONG&gt;.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I second that sentiment exactly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I find it easier to just delete unwanted fields with something like this. To me it is more logical and faster from what I have tried it on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ouput = #&amp;lt;feature class&amp;gt;
dropFields = list()
fieldList = gp.ListFields(output)
for f in fieldList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if f.name &amp;lt;&amp;gt; "BLOCKSTAGE" and f.type &amp;lt;&amp;gt; "OID" and f.type &amp;lt;&amp;gt; "Geometry":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Adding field to drop list "+f.name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dropFields.append(f.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.DeleteField_management(output, dropFields)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, ensure that the fields you are merging are the same data type.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 08:04:31 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2021-12-11T08:04:31Z</dc:date>
    <item>
      <title>Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149408#M11574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm new to python and using fieldmappings for the first time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a script that creates two dBASE tables.&amp;nbsp; I would like one of the final steps in my script to be merging these two tables and keeping only two fields (UCID and Temp).&amp;nbsp; In the table "statTableV" these fields are "UCID" and "MEAN".&amp;nbsp; In the table "pointValuesV" these fields are "CATCH_02_3" and "RASTERVALU".&amp;nbsp; So I need to rename the fields and merge them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wrote the code below based on the code example provided here: &lt;/SPAN&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id=949&amp;amp;pid=944&amp;amp;topicname=Mapping_fields" rel="nofollow noopener noreferrer" target="_blank"&gt;http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?id=949&amp;amp;pid=944&amp;amp;topicname=Mapping_fields&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;but that is resulting in this error: ExecuteError: ERROR 000468: Input shape types are not equal&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Merge).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Which brings me to my question:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a) What is causing the error?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;b) &lt;/SPAN&gt;&lt;STRONG&gt;Most of the fields in my input tables are ones I don't need.&amp;nbsp; Do I have to specify that they be removed in field mapping or with they be ignored if they are not specified in the code?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank-you&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import Modules
import arcgisscripting

# Create geoprocessor object
gp = arcgisscripting.create (9.3)

# Get parameters
catchments = r"F:\Climate\test\Catchments.gdb\Catch_02AA"
#catchments = gp.GetParameterAsText(0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Feature Layer
watershed = "02AA"
#watershed = gp.GetParameterAsText(1)
idField = "UCID"
#idField = gp.GetParameterAsText(2)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Field
climateRaster = r"F:\Climate\test\Climate.gdb\Avg_Temp_January"
#climateRaster = gp.GetParameterAsText(3)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Raster Layer
month = "January"
#month = gp.GetParameterAsText (4)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # String
workspace = r"F:\Climate\test\Climate.gdb"
#workspace = gp.GetParameterAsText (5)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Workspace
outWorkspace = r"F:\Climate\test"
#outWorkspace = gp.GetParameterAsText (6)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Folder

statTable = "zStat" + month
statTableV = "zStat" + month + "V"
missingStats = "zStat" + month + "Missing"
points = month + "Point"
pointValues = month + "PointValue"
pointValuesV = month + "PointValuesV"
finalTable = month + "Averages" + watershed
gp.Workspace = workspace
gp.overwriteoutput = True

# Check-out the Spatial Analyst extension
gp.CheckOutExtension ("Spatial")

# Run Zonal Statistics As Table
gp.ZonalStatisticsAsTable_sa (catchments, idField, climateRaster, statTable, "DATA")

# Create a feature layer from the catchments
gp.MakeFeatureLayer_management (catchments, "layer", "", workspace, "")

# Join zonal statistics table to catchments layer
gp.AddJoin_management ("layer", idField, statTable, idField, "KEEP_ALL")

# Select and export the catchments that don't have any zonal statistics
gp.Select_analysis ("layer", missingStats, '"' + statTable + "." + idField + '"' + ' is null')

# Un-join zonal statistics table from catchments
gp.RemoveJoin_management ("layer", statTable)

# Convert the exported "missing stats" catchments to point centroids
gp.FeatureToPoint_management (missingStats, points, "INSIDE")

# Add the underlying temperature values to the points
gp.ExtractValuesToPoints_sa (points, climateRaster, pointValues, "INTERPOLATE", "VALUE_ONLY")

# Make table views from the zonal statistics and value to points tables
gp.MakeTableView_management (statTable, statTableV, "", workspace, idField + " " + idField + " VISIBLE, RASTERVALU Temp VISIBLE")
gp.MakeTableView_management (pointValues, pointValuesV, "", workspace, idField + " " + idField + " VISIBLE, MEAN Temp VISIBLE")

# Convert table views to dBASE tables
gp.TableToDBASE_conversion (statTableV, outWorkspace)
gp.TableToDBASE_conversion (pointValuesV, outWorkspace)

# Prepare the field maps for the final table
fieldMappings = gp.createobject ("FieldMappings")
fldmap_UCID = gp.createobject ("FieldMap")
fldmap_Temp = gp.createobject ("FieldMap")
vt = gp.CreateObject("ValueTable")
fieldMappings.AddTable(statTableV)
fieldMappings.AddTable(pointValuesV)
fldmap_UCID.AddInputField(statTableV, "UCID")
fldmap_UCID.AddInputField(pointValuesV, "CATCH_02_3")
fldmap_Temp.AddInputField(statTableV, "MEAN")
fldmap_Temp.AddInputField(pointValuesV, "RASTERVALU")
fld_UCID = fldmap_UCID.OutputField
fld_Temp = fldmap_Temp.OutputField
fld_UCID.Name = "UCID"
fld_Temp.Name = "Temp"
fldmap_UCID.OutputField = fld_UCID
fldmap_Temp.OutputField = fld_Temp
fieldMappings.AddFieldMap(fldmap_UCID)
fieldMappings.AddFieldMap(fldmap_Temp)
vt.AddRow(statTableV)
vt.AddRow(pointValuesV)

# Merge the two tables
gp.Merge_management (vt, finalTable, fieldMappings)

# Delete all the temporary datasets
gp.Delete_management (statTable)
gp.Delete_management (missingStats)
gp.Delete_management (points)
gp.Delete_management (pointValues)
gp.Delete_management (statTableV + ".dbf")
gp.Delete_management (pointValuesV + ".dbf")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:04:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149408#M11574</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2021-12-11T08:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149409#M11575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are only editing the existing field map and dont delete them from the field map they will be transfered to your new feature class. You can create a new field map and only add the fields you want to that object though. I do not really like the field mapping functions very much.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Mar 2011 14:51:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149409#M11575</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2011-03-21T14:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149410#M11576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay, that makes sense and that is what I thought I was doing (adding the fields I want to a new field map).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas why this is causing an error?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Mar 2011 17:57:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149410#M11576</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2011-03-21T17:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149411#M11577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alright, I could use a fresh perspective on this again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been making slow progress, the merge function works if I do it without using a value table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The field mapping is not working, I am getting more fields than I like and they are all empty.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am having the strangest issue right now:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This line: print fieldMappings.GetFieldMap(16).OutputField.Name works perfectly&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However this block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
count = fieldMappings.FieldCount
print fieldMappings.GetFieldMap(16).OutputField.Name &lt;STRONG&gt;&amp;lt;&amp;lt;-- No error here&lt;/STRONG&gt;
for i in range (0, count-1, 1):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(i) + "/" + str(count-1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldMap = fieldMappings.GetFieldMap(i) &lt;STRONG&gt;&amp;lt;&amp;lt;----RuntimeError: FieldMappings: Error in getting field map from field mapping for GetFieldMap&lt;/STRONG&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; outField = fieldMap.OutputField
&amp;nbsp;&amp;nbsp;&amp;nbsp; print outField.Name
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fieldMappings.GetFieldMap(i) == fldmap_UCID:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Found UCID: " + str(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif outField.Name == "Temp":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Found Temp: " + str(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldMappings.RemoveFieldMap(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'done'
print 'done'&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;continues looping with no problem until it gets to i = 16.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am baffled.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:06:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149411#M11577</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2021-12-12T16:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149412#M11578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;fyi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What happened was everytime I ran through the loop, on of the field maps was deleted, which reset the index, so although there were 30 to begin with, by the time the loop got to index 16, there were only 15 field maps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I changed it so that instead of adding two tables and removing excess fields, I am now adding only the fields that I need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Except I am still getting empty tables in my output.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2011 14:47:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149412#M11578</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2011-03-23T14:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149413#M11579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you are only editing the existing field map and dont delete them from the field map they will be transfered to your new feature class. You can create a new field map and only add the fields you want to that object though.&lt;STRONG&gt; I do not really like the field mapping functions very much&lt;/STRONG&gt;.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I second that sentiment exactly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I find it easier to just delete unwanted fields with something like this. To me it is more logical and faster from what I have tried it on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ouput = #&amp;lt;feature class&amp;gt;
dropFields = list()
fieldList = gp.ListFields(output)
for f in fieldList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if f.name &amp;lt;&amp;gt; "BLOCKSTAGE" and f.type &amp;lt;&amp;gt; "OID" and f.type &amp;lt;&amp;gt; "Geometry":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Adding field to drop list "+f.name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dropFields.append(f.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.DeleteField_management(output, dropFields)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, ensure that the fields you are merging are the same data type.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:04:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149413#M11579</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T08:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149414#M11580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply, Matthew, I'm definitely jumping on the &lt;/SPAN&gt;&lt;STRONG&gt;I do not like field mapping functions&lt;/STRONG&gt;&lt;SPAN&gt; bandwagon.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've figured out my delete fields issue (by not adding them in the first place).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I checked to see if my field types were the same, for the first field (UCID) the inputs are both string.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For the second field (Temp) one input is a float, and the other is a double.&amp;nbsp; I have specified the output field as both float and double; both give me an empty output.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;They are both producing empty values though.&amp;nbsp; Do you think that the double/float conversion would cause both fields to fail?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I changed the output Temp field to double and it still gives me an empty output.&amp;nbsp; I'm not sure if/how I can change the input field types but I'll try.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2011 20:03:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149414#M11580</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2011-03-23T20:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149415#M11581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, attempting to merge fields of different data types is tricky at best. What I would do is create a field in each of your tables you are attempting to merge, with the same name and data type/structure, do a field calc or update cursor to copy the values from the original field to your new one, then merge your tables on those new fields.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2011 20:10:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149415#M11581</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-03-23T20:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149416#M11582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alright, I tried what you said,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I used add and calculate field to make sure that the input fields on all input tables are absolutely identical (string, 9 and float 5,1).&amp;nbsp; I checked these tables and the new fields are properly added and calculated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This still results in empty output table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Convert table views to dBASE tables
gp.TableToDBASE_conversion (statTableV, outWorkspace)
gp.TableToDBASE_conversion (pointValuesV, outWorkspace)
gp.Workspace = outWorkspace
# Convert the table views to geodatabase tables
#gp.TableToGeodatabase_conversion (statTableV, workspace)
#gp.TableToGeodatabase_conversion (pointValuesV, workspace)

# Change the temp fields to be float
gp.AddField_management (pointValuesV + ".dbf", "TempFloat", "FLOAT", 5, 1,"#","", "NULLABLE", "NON_REQUIRED","")
gp.CalculateField_management (pointValuesV + ".dbf", "TempFloat", "!RASTERVALU!", "PYTHON_9.3","")
gp.AddField_management (statTableV + ".dbf", "TempFloat2", "FLOAT", 5, 1, "#","", "NULLABLE", "NON_REQUIRED","")
gp.CalculateField_management (statTableV + ".dbf", "TempFloat2", "!MEAN!", "PYTHON_9.3","")

# Prepare the field maps for the final table
#* Create the field mappings object
fieldMappings = gp.createobject ("FieldMappings")
#* Create a UCID field map object and add the two UCID fields
fldmap_UCID = gp.CreateObject ("FieldMap")
fldmap_UCID.AddInputField(pointValuesV + ".dbf", "CATCH_02_3")
fldmap_UCID.AddInputField(statTableV + ".dbf", "UCID")
print "UCID input fields: " + str(fldmap_UCID.InputFieldCount)
#* Create a field map for temperature and add the two fields
fldmap_Temp = gp.createobject ("FieldMap")
fldmap_Temp.AddInputField(statTableV + ".dbf", "TempFloat2")
fldmap_Temp.AddInputField(pointValuesV + ".dbf", "TempFloat")
print "Temp input fields: " + str(fldmap_Temp.InputFieldCount)
#* Create both of the output fields and add them to the field mappings object
fld_UCID = fldmap_UCID.OutputField
fld_UCID.Name = "UCID"
fld_UCID.Type = "Text"
fld_UCID.Length = 9
fldmap_UCID.OutputField = fld_UCID
fieldMappings.AddFieldMap(fldmap_UCID)
fld_Temp = fldmap_Temp.OutputField
fld_Temp.Name = "Temp"
fld_Temp.Type = "Float"
fld_Temp.Precision = 5
fld_Temp.Scale = 1
fldmap_Temp.OutputField = fld_Temp
fieldMappings.AddFieldMap(fldmap_Temp)

# Merge the two tables
#gp.Merge_management (statTableV + ".dbf;" + pointValuesV + ".dbf", finalTable, fieldMappings)
gp.Merge_management (outWorkspace + "/" + statTableV + ".dbf;" + outWorkspace + "/" + pointValuesV + ".dbf", outWorkspace + "/" + finalTable, fieldMappings)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:04:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149416#M11582</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2021-12-11T08:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149417#M11583</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alrighty, let's see if I am following, so both input tables you are trying to merge are &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;F:\Climate\test\zStatJanuaryV.dbf&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;F:\Climate\test\JanuaryPointValuesV.dbf&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;They are populated with various fields, only two of which you are trying to merge, correct? The TempFloat and TempFloat2 which come from the UCID and RASTERVALU/MEAN fields. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you tried merging these two tables using the tools directly in catalog or arcmap? Does that work or do you get an error or the same empty output? You might also want to try using double \\ to avoid any confusion by python.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2011 13:25:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149417#M11583</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-03-24T13:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149418#M11584</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just switched "/" to "\\" and it works! So simple, thank-you so much.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I had a whole reply typed out, so I'll post it anyway in case anyone wants to know what I was trying to do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are almost correct&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My two input tables and the fields I am interested in are as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;F:\Climate\test\zStatJanuaryV.dbf UCID, TempFloat&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;F:\Climate\test\JanuaryPointValuesV.dbf Catch_02_3, TempFloat2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;output fields:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;UCID = zStatJanuaryV.UCID and JanuaryPointValuesV.Catch_02_3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Temp = zStatJanuaryV.TempFloat and JanuaryPointValuesV.TempFloat2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TempFloat is MEAN converted to float precision 5 scale 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TempFloat2 is RASTERVALU converted to float precision 5 scale 1&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2011 13:53:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149418#M11584</guid>
      <dc:creator>LornaMurison</dc:creator>
      <dc:date>2011-03-24T13:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149419#M11585</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No problem, those kinds of things are a real pain to track down. Python takes things so literally sometimes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Mar 2011 13:57:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149419#M11585</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2011-03-24T13:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149420#M11586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A similar Question has just been posed in &lt;/SPAN&gt;&lt;A href="http://gis.stackexchange.com/questions/30370/arcpy-error-in-adding-input-field-to-field-map/30397#30397"&gt;Stack Exchange GIS&lt;/A&gt;&lt;SPAN&gt; - thanks for having worked through this so thoroughly here so that I could offer your work as a possible/likely Answer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had major dramas with Field Mapping of Table To Table being unexpectedly reset in some very large models at 9.3 and was glad to see those resolved at 10.0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- Graeme&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Jul 2012 21:17:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149420#M11586</guid>
      <dc:creator>GraemeBrowning</dc:creator>
      <dc:date>2012-07-26T21:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149421#M11587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I second that sentiment exactly.&lt;BR /&gt;&lt;BR /&gt;I find it easier to just delete unwanted fields with something like this. To me it is more logical and faster from what I have tried it on.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
ouput = #&amp;lt;feature class&amp;gt;
dropFields = list()
fieldList = gp.ListFields(output)
for f in fieldList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if f.name &amp;lt;&amp;gt; "BLOCKSTAGE" and f.type &amp;lt;&amp;gt; "OID" and f.type &amp;lt;&amp;gt; "Geometry":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Adding field to drop list "+f.name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dropFields.append(f.name)
&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.DeleteField_management(output, dropFields)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also, ensure that the fields you are merging are the same data type.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello, this looks very close to what I'm trying to do, and failing at.&amp;nbsp; Instead of hard-coding the values "BLOCKSTAGE", "OID", etc., I'm wondering if there is a way to get those values from a list of fields in another fc.&amp;nbsp; In other words, I'd like to check against one fc and then and then delete any duplicate fields before I merge the two.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for any help you can offer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Adam&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:04:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149421#M11587</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2021-12-11T08:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149422#M11588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello, this looks very close to what I'm trying to do, and failing at.&amp;nbsp; Instead of hard-coding the values "BLOCKSTAGE", "OID", etc., I'm wondering if there is a way to get those values from a list of fields in another fc.&amp;nbsp; In other words, I'd like to check against one fc and then and then delete any duplicate fields before I merge the two.&lt;BR /&gt;&lt;BR /&gt;Thanks for any help you can offer.&lt;BR /&gt;Adam&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure I follow 100% but something like this should get you on your way. You may need to switch around which field list you loop through and which fc you are deleting from.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fc_target = #fc1
fc_merge = #fc2

fc_target_fields = [field.name for field in arcpy.ListFields(fc_target)]
fc_merge_fields = [field.name for field in arcpy.ListFields(fc_merge)]

dropFields = list()
for field in fc_target_fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if field in fc_merge_fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Adding field to drop list %s" % field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dropFields.append(field)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.DeleteField_management(fc_target, dropFields)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:04:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149422#M11588</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-11T08:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Field Mapping Help With Merge Tool</title>
      <link>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149423#M11589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Splendid, thanks a million.&amp;nbsp; Only thing I had to do was dedent the DeleteField line so that it did not try to run every time after checking each field.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Dec 2012 15:32:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/field-mapping-help-with-merge-tool/m-p/149423#M11589</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2012-12-20T15:32:37Z</dc:date>
    </item>
  </channel>
</rss>

