<?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: Creating a list that has strings not unicode in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236367#M66192</link>
    <description>&lt;P&gt;Hi I tried this option, and I am getting the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;TypeError: 'Row' object does not support indexing&lt;/P&gt;&lt;P&gt;I changed the arcpy.searchcursor out for the arcpy.da.searchcursor and all appears to be working.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2022 14:24:19 GMT</pubDate>
    <dc:creator>JacquelineAlessi</dc:creator>
    <dc:date>2022-11-30T14:24:19Z</dc:date>
    <item>
      <title>Creating a list that has strings not unicode</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236187#M66180</link>
      <description>&lt;P&gt;I am trying to use a search cursor to pull values as strings from a field and populate a list. Once the list is created, I need to loop through the list and pass the value be concatenated in a string that will then be passed to command line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my screen shot below you can see that I tried to options.&lt;/P&gt;&lt;P&gt;Here is an example of my code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;DeltaTable ='E:\\Data\\JRAlessi\\Conflation_URD_GPTest\\ConflationTest.gdb\\TestTable'&lt;BR /&gt;QTField = "QuarterTWNSHP"&lt;BR /&gt;cursor = arcpy.SearchCursor(DeltaTable, "FME_Status IS NULL")&lt;BR /&gt;QTSet = []&lt;BR /&gt;for row in cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;row.getValue(str(QTField))&lt;BR /&gt;&amp;nbsp; &amp;nbsp;QTset.append(str(row))&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JacquelineAlessi_0-1669759677209.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/57182iD88795F62F806CD5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JacquelineAlessi_0-1669759677209.png" alt="JacquelineAlessi_0-1669759677209.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong? when I go to print QTset I want to get back a true list that would look like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;['18644', '18643']&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 22:08:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236187#M66180</guid>
      <dc:creator>JacquelineAlessi</dc:creator>
      <dc:date>2022-11-29T22:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a list that has strings not unicode</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236196#M66181</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/row.htm" target="_blank"&gt;Row—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;don't str QTField or str row&lt;/P&gt;&lt;P&gt;try&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;val = row.getValue(QTField)
# add val = str(val) if you really need it&lt;/LI-CODE&gt;&lt;P&gt;and print should be print( ).&lt;/P&gt;&lt;P&gt;You are using python 3.x aren't you?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 22:10:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236196#M66181</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-11-29T22:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a list that has strings not unicode</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236209#M66182</link>
      <description>&lt;P&gt;Another option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
DeltaTable ='E:\\Data\\JRAlessi\\Conflation_URD_GPTest\\ConflationTest.gdb\\TestTable'
QTField = "QuarterTWNSHP"
QTSet = [str(row[0]) for row in arcpy.da.SearchCursor(DeltaTable, [QTField], "FME_Status IS NULL")]
print(QTSet)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 14:38:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236209#M66182</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-11-30T14:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a list that has strings not unicode</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236248#M66186</link>
      <description>&lt;P&gt;Firstly, don't use the old legacy &lt;FONT face="courier new,courier"&gt;arcpy.SearchCursor&lt;/FONT&gt;, use the newer, faster&amp;nbsp;&lt;FONT face="courier new,courier"&gt;arcpy.da.SearchCursor&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;See&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/2.9/arcpy/get-started/data-access-using-cursors.htm" target="_self"&gt;Data access using cursors&lt;/A&gt;:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;H5&gt;Legacy:&lt;/H5&gt;&lt;P&gt;The data access module (&lt;SPAN class=""&gt;arcpy.da&lt;/SPAN&gt;) was added in ArcGIS 10.1. The original cursors are still supported; however, the new&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;arcpy.da&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;cursors include significantly faster performance. In most cases, the help documentation describes the use of the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;arcpy.da&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;cursors. For more information about the classic cursor model, see the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.9/arcpy/functions/insertcursor.htm" target="_blank" rel="noopener"&gt;InsertCursor&lt;/A&gt;&lt;/SPAN&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.9/arcpy/functions/searchcursor.htm" target="_blank" rel="noopener"&gt;SearchCursor&lt;/A&gt;&lt;/SPAN&gt;, and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.9/arcpy/functions/updatecursor.htm" target="_blank" rel="noopener"&gt;UpdateCursor&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;topics.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Second, you need to access the value from the row, not the row itself:&lt;/P&gt;&lt;P&gt;Data access cursor example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(DeltaTable, [QTField], "FME_Status IS NULL") as cursor:
    QTSet = [row[0] for row in cursor]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or &lt;FONT face="courier new,courier"&gt;row.getValue(QTField)&lt;/FONT&gt; if you &lt;EM&gt;really&lt;/EM&gt; must use a legacy cursor...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 00:51:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236248#M66186</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-11-30T00:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a list that has strings not unicode</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236365#M66191</link>
      <description>&lt;P&gt;I'm kinda stuck with the version that I'm given.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this option and for whatever reason I am only getting a single return. Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 14:18:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236365#M66191</guid>
      <dc:creator>JacquelineAlessi</dc:creator>
      <dc:date>2022-11-30T14:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a list that has strings not unicode</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236367#M66192</link>
      <description>&lt;P&gt;Hi I tried this option, and I am getting the following error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;TypeError: 'Row' object does not support indexing&lt;/P&gt;&lt;P&gt;I changed the arcpy.searchcursor out for the arcpy.da.searchcursor and all appears to be working.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 14:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236367#M66192</guid>
      <dc:creator>JacquelineAlessi</dc:creator>
      <dc:date>2022-11-30T14:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a list that has strings not unicode</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236369#M66193</link>
      <description>&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/182709"&gt;@JacquelineAlessi&lt;/a&gt;,&amp;nbsp;I did not notice you were using the legacy cursor, as&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10780"&gt;@Luke_Pinner&lt;/a&gt;&amp;nbsp;pointed out. I updated my code to use the new data access cursor, but &lt;A href="https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236248/highlight/true#M66186" target="_self"&gt;the post from Luke is more complete&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 14:26:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-list-that-has-strings-not-unicode/m-p/1236369#M66193</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-11-30T14:26:09Z</dc:date>
    </item>
  </channel>
</rss>

