<?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: RemoveFieldMap doesn't work on AddJoin table views? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/removefieldmap-doesn-t-work-on-addjoin-table-views/m-p/678487#M52599</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes sir, it does! Nice use of the field mapping object, by the way. I may be able to make use of that technique in some of my own scripts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Micah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Aug 2017 18:50:08 GMT</pubDate>
    <dc:creator>MicahBabinski</dc:creator>
    <dc:date>2017-08-31T18:50:08Z</dc:date>
    <item>
      <title>RemoveFieldMap doesn't work on AddJoin table views?</title>
      <link>https://community.esri.com/t5/python-questions/removefieldmap-doesn-t-work-on-addjoin-table-views/m-p/678484#M52596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have AddJoined two tables as a table view. Now I want to remove very many fields. I want to operate on this table in memory before I export it because the table is very large and it takes a very long time to export. So, I am starting by reducing the number of fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the code below, I am using tiny little tables for testing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand "for field" loop. But I don't understand why it doesn't remove the fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I print(field.name) as a sanity check. The joined fields of the table view are all there. Then, I export the addjoin table (TableToTable_conversion) to see if the fields really have been removed. They aren't. The exported table contains all original fields. The problem seems to be in the line:&amp;nbsp;&lt;SPAN&gt;fieldmappings.removeFieldMap. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Question: Does FieldMappings.RemoveFieldMap only work on "real" tables, and not on tableviews? Or perhaps it doesn't work on AddJoins?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for any suggestion.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards, Mike&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;# Make the VAA table view&lt;/P&gt;&lt;P&gt;mr_vaa_view = 'mr_vaa_table_view'&lt;/P&gt;&lt;P&gt;arcpy.MakeTableView_management(mr_vaa, mr_vaa_view)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Join the VAA table to the flowlines&lt;BR /&gt;# Must turn the VAA and Flowlines into a table view.&lt;BR /&gt;# Because AddJoin only works on layers and views&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Make the VAA table view#&lt;BR /&gt;mr_vaa_view = 'mr_vaa_table_view'&lt;BR /&gt;arcpy.MakeTableView_management(mr_vaa, mr_vaa_view)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Make the MR Flowlines&amp;nbsp;table view#&lt;/P&gt;&lt;P&gt;mr_fl_lyr = 'mr_flowlines_layer'&lt;/P&gt;&lt;P&gt;arcpy.MakeTableView_management(mr_fl_table,mr_fl_lyr)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# AddJoin the VAA table, (mr_vaa_view) to the Flowline table, (mr_fl_table)#&lt;/P&gt;&lt;P&gt;addjoin = arcpy.AddJoin_management(mr_fl_lyr, 'Permanent_Identifier', mr_vaa_view, 'ComIDstr', 'KEEP_COMMON')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Reduce the number of fields to the essentials#&lt;/P&gt;&lt;P&gt;fieldmappings = arcpy.FieldMappings()&lt;/P&gt;&lt;P&gt;fieldmappings.addTable(addjoin)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Name fields I want to keep#&lt;/P&gt;&lt;P&gt;keepers = ["ReachCode", "FlowFlowlineVAACopy_Hydroseq","COMstr"]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Remove fields I don't want#&lt;/P&gt;&lt;P&gt;for field in fieldmappings.fields:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;print(field.name)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if field.name not in keepers:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex(field.name))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;name = 'MR_VAA'&lt;/P&gt;&lt;P&gt;out_folder = 'D:\output'&lt;/P&gt;&lt;P&gt;outputGDB = 'output.gdb'&lt;/P&gt;&lt;P&gt;mr_nhd_vaa = os.path.join(out_folder, outputGDB)&lt;/P&gt;&lt;P&gt;arcpy.TableToTable_conversion(addjoin, mr_nhd_vaa, name)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Aug 2017 17:44:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removefieldmap-doesn-t-work-on-addjoin-table-views/m-p/678484#M52596</guid>
      <dc:creator>MichaelTinker</dc:creator>
      <dc:date>2017-08-31T17:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: RemoveFieldMap doesn't work on AddJoin table views?</title>
      <link>https://community.esri.com/t5/python-questions/removefieldmap-doesn-t-work-on-addjoin-table-views/m-p/678485#M52597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your Table to Table function it looks like you've omitted the field mappings object from the parameters. Try something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TableToTable_conversion&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;addjoin&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; mr_nhd_vaa&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; "&lt;SPAN class="comment token"&gt;#", fieldmappings)‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also &amp;nbsp;it helps to post your code using the Syntax highlighter (under the "More" menu in the formatting widgets) to make it a bit more readable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Micah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Aug 2017 18:14:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removefieldmap-doesn-t-work-on-addjoin-table-views/m-p/678485#M52597</guid>
      <dc:creator>MicahBabinski</dc:creator>
      <dc:date>2017-08-31T18:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: RemoveFieldMap doesn't work on AddJoin table views?</title>
      <link>https://community.esri.com/t5/python-questions/removefieldmap-doesn-t-work-on-addjoin-table-views/m-p/678486#M52598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Micah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you, that did the trick! And thanks for the heads up on the Syntax highlighter, I will use it next time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, what does "#" mean? Does this mean to ignore that parameter?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Aug 2017 18:49:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removefieldmap-doesn-t-work-on-addjoin-table-views/m-p/678486#M52598</guid>
      <dc:creator>MichaelTinker</dc:creator>
      <dc:date>2017-08-31T18:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: RemoveFieldMap doesn't work on AddJoin table views?</title>
      <link>https://community.esri.com/t5/python-questions/removefieldmap-doesn-t-work-on-addjoin-table-views/m-p/678487#M52599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes sir, it does! Nice use of the field mapping object, by the way. I may be able to make use of that technique in some of my own scripts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Micah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Aug 2017 18:50:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removefieldmap-doesn-t-work-on-addjoin-table-views/m-p/678487#M52599</guid>
      <dc:creator>MicahBabinski</dc:creator>
      <dc:date>2017-08-31T18:50:08Z</dc:date>
    </item>
  </channel>
</rss>

