<?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: Generate a list for Transpose Fields tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/generate-a-list-for-transpose-fields-tool/m-p/3343#M306</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you've already got your list in the format below, just use ';'.join(list) to insert semi-colons in between list items and return the string:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; my_list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field1a field1b'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field2a field2b'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field3a field3b'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field4a field4b'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; delimited_list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;';'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;my_list&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; delimited_list
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; 
field1a field1b&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;field2a field2b&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;field3a field3b&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;field4a field4b&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 20:08:46 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2021-12-10T20:08:46Z</dc:date>
    <item>
      <title>Generate a list for Transpose Fields tool</title>
      <link>https://community.esri.com/t5/python-questions/generate-a-list-for-transpose-fields-tool/m-p/3342#M305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to generate the inputs for arcpy.TransposeFields_management and I am running into a problem with the list that feeds the FieldsToTranspose. &amp;nbsp;If I run the tool manually, and then save the code as a python snippet, this is how the fields are specified in the snippet: &amp;nbsp;&lt;/P&gt;&lt;P&gt;in_field="A_4431 4431;A_1111 1111" &amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I am trying to create a list of my fields that follows that format, but this eludes me. Here is the code I have been working with - see the explanation in the comments for what happens when I run it… &amp;nbsp;&lt;/P&gt;&lt;P&gt;# Set local variables&lt;/P&gt;&lt;P&gt;InTable = "C:\Distubance\OutTab.gdb\FACTS_Code_2010_1"&lt;/P&gt;&lt;P&gt;# Specify fields to transpose FieldNames = arcpy.ListFields(InTable, "A*")&lt;/P&gt;&lt;P&gt;OrigFieldNames = []&lt;/P&gt;&lt;P&gt;FieldShortNames = []&lt;/P&gt;&lt;P&gt;for f in FieldNames: &lt;SPAN class=""&gt; &lt;/SPAN&gt;OrigFieldNames.append(f.name)&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt;FieldShortNames.append(f.name[2:6])&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt; &lt;/SPAN&gt; #To generate a list of the old field names and the new, desired field names to use in the Transpose tool, I tried this: FieldsToTranspose = [OrigFieldNames&lt;I&gt; + " " + FieldShortNames&lt;I&gt; for i in xrange(len(OrigFieldNames))] # This generates a nice list, the tool runs and the output table is generated, but that table is empty. &amp;nbsp;&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;# Set a variable to store output feature class or table&lt;/P&gt;&lt;P&gt;outTable = "TestTab"&lt;/P&gt;&lt;P&gt;# Set a variable to store code field name&lt;/P&gt;&lt;P&gt;TransposedFieldName = "FCode"&lt;/P&gt;&lt;P&gt;# Set a variable to store value field name&lt;/P&gt;&lt;P&gt;ValueFieldName = "AreaM2"&lt;/P&gt;&lt;P&gt;# Specify attribute field to be included in the output&lt;/P&gt;&lt;P&gt;AttrFields = "ZSID"&lt;/P&gt;&lt;P&gt;# Execute&lt;/P&gt;&lt;P&gt;TransposeFields arcpy.TransposeFields_management(InTable, FieldsToTranspose, outTable, TransposedFieldName, ValueFieldName, AttrFields)&lt;SPAN class=""&gt; &lt;/SPAN&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone have an idea how I can either generate the list with the proper formatting in the first place, or modify the list to follow the correct formatting, after I generate it using the method above?&lt;/P&gt;&lt;P&gt;Thanks much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2016 20:51:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/generate-a-list-for-transpose-fields-tool/m-p/3342#M305</guid>
      <dc:creator>EvaKarau</dc:creator>
      <dc:date>2016-12-05T20:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Generate a list for Transpose Fields tool</title>
      <link>https://community.esri.com/t5/python-questions/generate-a-list-for-transpose-fields-tool/m-p/3343#M306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you've already got your list in the format below, just use ';'.join(list) to insert semi-colons in between list items and return the string:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; my_list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field1a field1b'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field2a field2b'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field3a field3b'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'field4a field4b'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; delimited_list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;';'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;my_list&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; delimited_list
&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; 
field1a field1b&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;field2a field2b&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;field3a field3b&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;field4a field4b&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:08:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/generate-a-list-for-transpose-fields-tool/m-p/3343#M306</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-10T20:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Generate a list for Transpose Fields tool</title>
      <link>https://community.esri.com/t5/python-questions/generate-a-list-for-transpose-fields-tool/m-p/3344#M307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow. That alone seems to have done the trick! Thanks much, Darren.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2016 21:24:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/generate-a-list-for-transpose-fields-tool/m-p/3344#M307</guid>
      <dc:creator>EvaKarau</dc:creator>
      <dc:date>2016-12-05T21:24:44Z</dc:date>
    </item>
  </channel>
</rss>

