<?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: How to use Field Mappings in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-use-field-mappings/m-p/482089#M37688</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is how I'm using field mappings for my street index creator hope this helps&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/fieldmappings.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/fieldmappings.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/fieldmappings.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Create a new fieldmappings and add the two input feature classes.
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(DissolvedStreets)
fieldmappings.addTable(InputGrid)


jField = fieldmappings.findFieldMapIndex(gridField)
fieldmap = fieldmappings.getFieldMap(jField)


fieldmap.mergeRule = "join"
fieldmap.joinDelimiter = ","
fld_length = fieldmap.outputField
fld_length.length = 255
fieldmap.outputField = fld_length
arcpy.AddMessage(str(fieldmap.outputField.length))
fieldmappings.replaceFieldMap(jField, fieldmap)


# Process: Spatial Join
arcpy.SpatialJoin_analysis(DissolvedStreets, InputGrid, outfc, "#", "#", fieldmappings)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 21:16:39 GMT</pubDate>
    <dc:creator>WesMiller</dc:creator>
    <dc:date>2021-12-11T21:16:39Z</dc:date>
    <item>
      <title>How to use Field Mappings</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-field-mappings/m-p/482088#M37687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to understand how to use the FieldMappings object in arcpy, but am getting confused.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have two tables, an input table and a target table.&amp;nbsp; I'm trying to use the Append tool to load data from the input table into the target table.&amp;nbsp; I have two fields within each table that need to be mapped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Input&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;NEAR_FID&lt;/P&gt;&lt;P&gt;BUFF_DIST&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Target&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;WellOID&lt;/P&gt;&lt;P&gt;Distance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Mapping should be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;NEAR_FID = WellOID&lt;/P&gt;&lt;P&gt;BUFF_DIST = Distance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on how to map these fields using the FieldMappings object would be greatly appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Sep 2015 18:48:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-field-mappings/m-p/482088#M37687</guid>
      <dc:creator>mpboyle</dc:creator>
      <dc:date>2015-09-14T18:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Field Mappings</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-field-mappings/m-p/482089#M37688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is how I'm using field mappings for my street index creator hope this helps&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/fieldmappings.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/fieldmappings.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-classes/fieldmappings.htm&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Create a new fieldmappings and add the two input feature classes.
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(DissolvedStreets)
fieldmappings.addTable(InputGrid)


jField = fieldmappings.findFieldMapIndex(gridField)
fieldmap = fieldmappings.getFieldMap(jField)


fieldmap.mergeRule = "join"
fieldmap.joinDelimiter = ","
fld_length = fieldmap.outputField
fld_length.length = 255
fieldmap.outputField = fld_length
arcpy.AddMessage(str(fieldmap.outputField.length))
fieldmappings.replaceFieldMap(jField, fieldmap)


# Process: Spatial Join
arcpy.SpatialJoin_analysis(DissolvedStreets, InputGrid, outfc, "#", "#", fieldmappings)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:16:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-field-mappings/m-p/482089#M37688</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2021-12-11T21:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Field Mappings</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-field-mappings/m-p/482090#M37689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Following might help a bit:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# define new mappings and load default from fc or table
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(yourFCorTable)


# now you define the ouput fields
fieldmap1 = fieldmappings.getFieldMap(1)
outField1 = fieldmap.outputField
outField1.name = "WellOID"
outField1.aliasName = "WellOID"
fieldmap1.outputField = outField1


fieldmap2 = fieldmappings.getFieldMap(2)
outField2 = fieldmap2.outputField
outField2.name = "Distance"
outField2.aliasName = "Distance"
fieldmap2.outputField = outField2


# now you can use your field mappings&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:16:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-field-mappings/m-p/482090#M37689</guid>
      <dc:creator>MahtabAlam1</dc:creator>
      <dc:date>2021-12-11T21:16:42Z</dc:date>
    </item>
  </channel>
</rss>

