<?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: TextToColumns in Excel with win32com and arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/texttocolumns-in-excel-with-win32com-and-arcpy/m-p/582956#M45688</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to you both for some great insight! Owen, your suggestion of adding both original fields to the DBF motivated me to look at the documentation for arcpy.Statistics_analysis(), which is what I was using originally to create it, and gave me the answer!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A second look at the documentation shows that you can actually use a combination of fields to create unique values for the case field on which to summarize. The code I was using originally was this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14181618919478183" jivemacro_uid="_14181618919478183"&gt;&lt;P&gt;arcpy.Statistics_analysis(outputPoly, outputDBFTable, [["LithPerc", "SUM"]], "ConcatField")&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I ended up using that worked was this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14181619041445614 jive_text_macro" jivemacro_uid="_14181619041445614"&gt;&lt;P&gt;arcpy.Statistics_analysis(outputPoly, outputDBFTable, [["LithPerc", "SUM"]], ["ROCKTYPE1","ROCKTYPE2"])&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This allows you to summarize unique values but also maintain the original, separate fields. Cool!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Dec 2014 21:53:46 GMT</pubDate>
    <dc:creator>KateJohnson</dc:creator>
    <dc:date>2014-12-09T21:53:46Z</dc:date>
    <item>
      <title>TextToColumns in Excel with win32com and arcpy</title>
      <link>https://community.esri.com/t5/python-questions/texttocolumns-in-excel-with-win32com-and-arcpy/m-p/582953#M45685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have searched extensively but can't really find any good documentation on using the TextToColumns method within Excel using win32com. The VB developer help gives the following example, but translating the parameters into Python has been a challenge.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VBA:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Worksheets("Sheet1").Activate
ActiveSheet.Paste
Selection.&lt;STRONG&gt;TextToColumns&lt;/STRONG&gt; DataType:=xlDelimited, _
&amp;nbsp; ConsecutiveDelimiter:=True, Space:=True&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I currently have takes 2 fields in a shapefile and concatenates them together with a "_" for unique identifier summarizing purposes while in ArcGIS, i.e.,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;exRock = "!ROCKTYPE1!+'_'+!ROCKTYPE2!"&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once the tables are exported to DBF and then converted to an XLS file, I want to separate the fields again based on the "_".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there is an easier way to do this without Excel any insights would be appreciated! I have tried using the .partition() method and csv files/strings however I can't get that to work correctly either.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:03:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/texttocolumns-in-excel-with-win32com-and-arcpy/m-p/582953#M45685</guid>
      <dc:creator>KateJohnson</dc:creator>
      <dc:date>2021-12-12T01:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: TextToColumns in Excel with win32com and arcpy</title>
      <link>https://community.esri.com/t5/python-questions/texttocolumns-in-excel-with-win32com-and-arcpy/m-p/582954#M45686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the split method on strings in python should do it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;s = 'hello world'&lt;/P&gt;&lt;P&gt;a,b = s.split(' ')&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;&lt;P&gt;hello&lt;/P&gt;&lt;P&gt;b&lt;/P&gt;&lt;P&gt;world&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm splitting on a single whitespace here, but you could use a comma or another delimter the same.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 20:50:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/texttocolumns-in-excel-with-win32com-and-arcpy/m-p/582954#M45686</guid>
      <dc:creator>KevinBell</dc:creator>
      <dc:date>2014-12-09T20:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: TextToColumns in Excel with win32com and arcpy</title>
      <link>https://community.esri.com/t5/python-questions/texttocolumns-in-excel-with-win32com-and-arcpy/m-p/582955#M45687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just include the two original fields in the DBF as well as the concatenated ID value?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have to do this in Excel you can use formulas:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;ExRock&lt;/TD&gt;&lt;TD&gt;RockType1&lt;/TD&gt;&lt;TD&gt;RockType2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Andesite_Basalt&lt;/TD&gt;&lt;TD&gt;Andesite&lt;/TD&gt;&lt;TD&gt;Basalt&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Basalt_Granite&lt;/TD&gt;&lt;TD&gt;Basalt&lt;/TD&gt;&lt;TD&gt;Granite&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ROCKTYPE1&lt;/P&gt;&lt;P&gt;=LEFT(A2,(FIND("_",A2) - 1))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ROCKTYPE2&lt;/P&gt;&lt;P&gt;=RIGHT(A2, LEN(A2) - FIND("_",A2))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise, if you are processing this within python then use split('_") as Kevin suggests.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 21:24:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/texttocolumns-in-excel-with-win32com-and-arcpy/m-p/582955#M45687</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2014-12-09T21:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: TextToColumns in Excel with win32com and arcpy</title>
      <link>https://community.esri.com/t5/python-questions/texttocolumns-in-excel-with-win32com-and-arcpy/m-p/582956#M45688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks to you both for some great insight! Owen, your suggestion of adding both original fields to the DBF motivated me to look at the documentation for arcpy.Statistics_analysis(), which is what I was using originally to create it, and gave me the answer!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A second look at the documentation shows that you can actually use a combination of fields to create unique values for the case field on which to summarize. The code I was using originally was this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14181618919478183" jivemacro_uid="_14181618919478183"&gt;&lt;P&gt;arcpy.Statistics_analysis(outputPoly, outputDBFTable, [["LithPerc", "SUM"]], "ConcatField")&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I ended up using that worked was this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14181619041445614 jive_text_macro" jivemacro_uid="_14181619041445614"&gt;&lt;P&gt;arcpy.Statistics_analysis(outputPoly, outputDBFTable, [["LithPerc", "SUM"]], ["ROCKTYPE1","ROCKTYPE2"])&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This allows you to summarize unique values but also maintain the original, separate fields. Cool!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 21:53:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/texttocolumns-in-excel-with-win32com-and-arcpy/m-p/582956#M45688</guid>
      <dc:creator>KateJohnson</dc:creator>
      <dc:date>2014-12-09T21:53:46Z</dc:date>
    </item>
  </channel>
</rss>

