<?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: arcpy.da.SearchCursor got the unexpected string from the field in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026674#M38504</link>
    <description>&lt;P&gt;Just a reminder: OP is working in ArcMap 10.6.&lt;/P&gt;&lt;P&gt;But, thank you, that new environment setting is useful! Why I hang out here, you always learn something.&lt;/P&gt;&lt;P&gt;Snap I didn't see there were answers already - still getting used to the new interface.&lt;/P&gt;</description>
    <pubDate>Sun, 14 Feb 2021 17:01:42 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-02-14T17:01:42Z</dc:date>
    <item>
      <title>arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026624#M38487</link>
      <description>&lt;P&gt;Hi, there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am learning Arcpy from ArcGIS Desktop 10.6.1. I have a &lt;SPAN&gt;feature class&lt;/SPAN&gt;&amp;nbsp;which has a field called "CondSize". This field has some texts such as '1/0', '2/0', '500', '1' etc. When I used the below python code, it gave me the different strings such as r'43', r'37', etc. I also tried to use str(row[0]), but no luck. I know the issue came from '/' in some strings in the field. But I don't know how to get the original strings.&amp;nbsp;Your clue is appreciated.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;with &lt;/SPAN&gt;arcpy.da.SearchCursor(&lt;SPAN&gt;fc&lt;/SPAN&gt;, [&lt;SPAN&gt;'CondSize'&lt;/SPAN&gt;]) &lt;SPAN&gt;as &lt;/SPAN&gt;cursor:&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;row &lt;SPAN&gt;in &lt;/SPAN&gt;cursor:&lt;BR /&gt;        &lt;SPAN&gt;print row[0]&lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;&lt;P&gt;Eddy. H.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 01:34:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026624#M38487</guid>
      <dc:creator>SLH</dc:creator>
      <dc:date>2021-02-14T01:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026628#M38488</link>
      <description>&lt;H3&gt;Try to replace your printing string to be formatted as a Unicode string :&lt;BR /&gt;print (u'{0}'.format(row[0]))&lt;/H3&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 02:33:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026628#M38488</guid>
      <dc:creator>VickyWang</dc:creator>
      <dc:date>2021-02-14T02:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026632#M38490</link>
      <description>&lt;P&gt;Hi, Vicky, thanks for the reply. I have tried it, but it is still same issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 03:06:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026632#M38490</guid>
      <dc:creator>SLH</dc:creator>
      <dc:date>2021-02-14T03:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026634#M38491</link>
      <description>&lt;P&gt;Can you provide specifics on the field type.&lt;/P&gt;&lt;P&gt;Is definitely a string/text field or something else?&lt;/P&gt;&lt;P&gt;Are there missing values?&lt;/P&gt;&lt;P&gt;And regionalization/language settings?&lt;/P&gt;&lt;P&gt;Have you tried&amp;nbsp; the TableToExcel tool to examine the table in Excel?&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 03:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026634#M38491</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-14T03:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026638#M38492</link>
      <description>&lt;P&gt;Hi, Dan,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I double checked the field and copied it as below. It is text. And also I tried to export it as txt file and excel file. It is same issue there:&amp;nbsp; it&lt;SPAN&gt;&amp;nbsp;gave me the different strings such as r'43', r'37', etc&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Eddy H.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SLH_1-1613273792232.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/5979iD0444BE774DD5903/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SLH_1-1613273792232.png" alt="SLH_1-1613273792232.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 03:45:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026638#M38492</guid>
      <dc:creator>SLH</dc:creator>
      <dc:date>2021-02-14T03:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026639#M38493</link>
      <description>&lt;P&gt;weird... or the field is weird.&amp;nbsp; Try adding a new text field to the table and do a simple field calculate, python parser&amp;nbsp; eg your new field would equal&lt;/P&gt;&lt;P&gt;!Condsize!&amp;nbsp;&lt;/P&gt;&lt;P&gt;if that doesn't work try a couple of other variants like&lt;/P&gt;&lt;P&gt;val = str(row[0]).replace("\\", "_")&lt;/P&gt;&lt;P&gt;print(val)&lt;/P&gt;&lt;P&gt;I just want to check to see if it can be converted to pure text and replacing the backslashes with underscores or not.&lt;/P&gt;&lt;P&gt;Best check is get on an ArcGIS Pro machine and try it with python 3.7.&amp;nbsp; python 2.7 is done as is the arcmap series (although it will remain on support for the foreseeable future.&lt;/P&gt;&lt;P&gt;It doesn't appear that the unicode or raw encoding worked for you (?!) but again, you are using python 2.7&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 03:59:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026639#M38493</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-14T03:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026642#M38494</link>
      <description>&lt;P&gt;feel wired about the field too.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used ArcMap 10.8.1 with Unicode string formation that works. try to replace the string as what&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp;suggests. replace by two backslashes.&lt;/P&gt;&lt;P&gt;Create a new field and use field calculation to convert the existing field value to string in the new field.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 04:21:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026642#M38494</guid>
      <dc:creator>VickyWang</dc:creator>
      <dc:date>2021-02-14T04:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026645#M38495</link>
      <description>&lt;P&gt;his problem isn't backslashes, but foreslashes&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;'1/0',&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;which makes it more confusing, hence the suggestion of replacing with anything other than a slash&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 10:42:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026645#M38495</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-14T10:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026646#M38496</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thanks for the correction&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 10:47:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026646#M38496</guid>
      <dc:creator>VickyWang</dc:creator>
      <dc:date>2021-02-14T10:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026648#M38497</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/19313"&gt;@VickyWang&lt;/a&gt;&amp;nbsp;, sorry for the confusion, I meant any "slash" since they have meaning in unicode (see "solidus" in unicode).&amp;nbsp; By replacing and \,/ with _ removes those from causing a misinterpretation of anything before or after it.&lt;/P&gt;&lt;P&gt;In any event ArcGIS Pro and python 3 would be a better test&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 10:49:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026648#M38497</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-14T10:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026657#M38498</link>
      <description>&lt;P&gt;Is it not just returning the coded value domain number?&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 13:57:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026657#M38498</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-14T13:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026658#M38499</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/167692"&gt;@DavidPike&lt;/a&gt;&amp;nbsp; mentions . I think something is wrong with your domain. Check what is going on with your domain on that field or remove the domain from the field and try your code again.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 14:19:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026658#M38499</guid>
      <dc:creator>Amadeus111</dc:creator>
      <dc:date>2021-02-14T14:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026665#M38500</link>
      <description>&lt;P&gt;Dear &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/452333"&gt;@SLH&lt;/a&gt; --&lt;/P&gt;&lt;P&gt;Your CondSize field has a coded domain applied to it.&lt;/P&gt;&lt;P&gt;This means that what is displayed in a table and in the attribute window and the identify tool is &lt;STRONG&gt;not&lt;/STRONG&gt; the &lt;EM&gt;value&lt;/EM&gt; in the field, but the &lt;EM&gt;description&lt;/EM&gt; from the domain. your values 43, 37 are codes in the domain and values like 1/0, 2/0 are descriptions of those codes. This is very handy as it allows you to efficiently store and handle &lt;EM&gt;codes&lt;/EM&gt; in fields - but expose easily understood text descriptions while editing and displaying the data.&lt;/P&gt;&lt;P&gt;To see the domain, go and look for it by right clicking your geodatabase where the feature class lives and select Domains and find the ConductorSize domain and look at its codes and descriptions.&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/latest/manage-data/editing-attributes/about-maintaining-attribute-integrity-while-editing.htm" target="_self"&gt;ArcGIS ArcMap help: Maintaining attribute integrity while editing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;ArcMap has an option to display the data instead of the code descriptions if you want.&lt;/P&gt;&lt;P&gt;Customize &amp;gt; ArcMap Options &amp;gt; Tables - uncheck the box "Display coded value domains and subtype descriptions"&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 16:59:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026665#M38500</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-02-14T16:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026672#M38503</link>
      <description>&lt;P&gt;I think a few people have converged on this being your Domain value being returned rather than the description.&lt;/P&gt;&lt;P&gt;The post here details it well, along with a dictionary solution by&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1147"&gt;@RussellBrennan&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;A href="https://community.esri.com/t5/python-questions/accessing-coded-domain-values-using-python/td-p/18100" target="_blank"&gt;Solved: Accessing Coded Domain Values using python - GeoNet, The Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/65062"&gt;@BrandonBarnett&lt;/a&gt;&amp;nbsp;also links to&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/environment-settings/transfergdbattributeproperties.htm" target="_blank"&gt;Transfer Geodatabase Field Properties (Environment setting)—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;- an environment setting.&amp;nbsp; I'm unsure if this will work with a cursor but it is worth a go for a single additional line of code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Set the transferGDBAttributeProperties environment to True
arcpy.env.transferGDBAttributeProperties = True&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 14 Feb 2021 16:33:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026672#M38503</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-14T16:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026674#M38504</link>
      <description>&lt;P&gt;Just a reminder: OP is working in ArcMap 10.6.&lt;/P&gt;&lt;P&gt;But, thank you, that new environment setting is useful! Why I hang out here, you always learn something.&lt;/P&gt;&lt;P&gt;Snap I didn't see there were answers already - still getting used to the new interface.&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 17:01:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026674#M38504</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-02-14T17:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026677#M38505</link>
      <description>&lt;P&gt;Au contraire, I believe the coded domain is working exactly as it should!&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 16:39:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026677#M38505</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-02-14T16:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.SearchCursor got the unexpected string from the field</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026682#M38507</link>
      <description>&lt;P&gt;Thank everyone for the reply. Yes, as&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/167692"&gt;@DavidPike&lt;/a&gt;&amp;nbsp;mentioned, it was&amp;nbsp;&lt;SPAN&gt;returning the coded value domain number. So I changed python code to create a new table, and then created a dictionary for number/Description to solve it. I posted the below code to benefit other learners like me. Thank everyone again!!!&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;arcpy.DomainToTable_management(gdbfile, &lt;SPAN&gt;'CondSize'&lt;/SPAN&gt;, &lt;SPAN&gt;"in_memory\CONDSIZE"&lt;/SPAN&gt;, &lt;SPAN&gt;"CODE"&lt;/SPAN&gt;, &lt;SPAN&gt;"DESCRIPTION"&lt;/SPAN&gt;)&lt;BR /&gt;CodeDict = {}&lt;BR /&gt;rows = arcpy.SearchCursor(&lt;SPAN&gt;"in_memory\CONDSIZE"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;row &lt;SPAN&gt;in r&lt;/SPAN&gt;ows:&lt;BR /&gt;    CodeDict[row.CODE] = row.DESCRIPTION&lt;BR /&gt;    &lt;SPAN&gt;print &lt;/SPAN&gt;(row.CODE, row.DESCRIPTION)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 18:24:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcpy-da-searchcursor-got-the-unexpected-string/m-p/1026682#M38507</guid>
      <dc:creator>SLH</dc:creator>
      <dc:date>2021-02-14T18:24:02Z</dc:date>
    </item>
  </channel>
</rss>

