<?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 - Check a field type and execute depending on the type in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190630#M14627</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, I was looking at the return value for the next() method. I see the second second sentence at the very beginning clearly says:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Returns an iterator of lists.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;But down at the bottom under the Method overview for next(), it says:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Returns the next row as a tuple.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I tested both the next() method and just iterating through the whole cursor in a for loop and both give the row as a list (like you said). &lt;STRONG&gt;Esri's documentation for the next() method is just wrong.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Mar 2015 16:51:18 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2015-03-17T16:51:18Z</dc:date>
    <item>
      <title>ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190621#M14618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure if this is the right place to send this so please correct me if I am wrong.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had a script that converted data from a clients site to a usable GIS format until they changed the output.&amp;nbsp; I've tried two different directions with no luck.&amp;nbsp; Due to how an earlier part of the script works, CSV to Table, and the nature of the data being converted; the 'total_length' field that's imported might end up being a string or an integer (TableToTable conversion will not work).&amp;nbsp; I need it to look at the field type and if it's already an integer then populate the 'length_val' field with the number.&amp;nbsp; If it's a string then strip it down to the number (typically the greater than, less than or tilde off the front) and populate the 'length_val' field.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In other words:&lt;/P&gt;&lt;P&gt;If 'total_length' = STRING, then send only the number to 'length_val'&lt;/P&gt;&lt;P&gt;Otherwise, if 'total_length' = INTEGER, then calculate the field.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been using update cursors to do a lot of the rest of the work, but that doesn't have to be the case.&amp;nbsp; Any assistance would be great.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Row[3] = 'total_length'&lt;/P&gt;&lt;P&gt;Row[17] = 'length_val'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;---First Attempt---&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with arcpy.da.UpdateCursor(aoi_table_gdb,aoi_fields) as cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; totlen = "total_length"&amp;nbsp; #&amp;lt;--- This was just an idea&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fields = arcpy.ListFields(aoi_table_gdb)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fields:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if field.name = '"'+ totlen +'"' and field.type = String:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[3] == None:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[17] = None&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif row[3].find(str('~ ')) &amp;gt; -1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[17] = row[3].lstrip(str('~ '))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif row[3].find(str('&amp;gt; ')) &amp;gt; -1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[17] = row[3].lstrip(str('&amp;gt; '))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif row[3].find(str('&amp;lt; ')) &amp;gt; -1:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[17] = row[3].lstrip(str('&amp;lt; '))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[17] = row[3]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[17] = row[3]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;---Second Attempt---&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with arcpy.da.UpdateCursor(aoi_table_gdb,aoi_fields) as cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Length Value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if row[3] == None:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[17] = None&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddWarning("A. Row: " + str(row[1]) + " - " + str(row[3]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif row[3].isdigit():&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[17] = row[3]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddWarning("B. Row: " + str(row[1]) + " - " + str(row[3]))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length = filter(unicode.isdigit, row[3])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[17] = length&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddWarning("C. Row: " + str(row[1]) + " - " + str(row[3]))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2015 18:00:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190621#M14618</guid>
      <dc:creator>JohnSemanchik</dc:creator>
      <dc:date>2015-03-13T18:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190622#M14619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In your first script, the line should be:&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_14262723433366219" data-renderedposition="50_8_912_16" jivemacro_uid="_14262723433366219"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;if field.name == 'total_length' and field.type == 'String':&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;There are other logic issues in the first script, too. For example, it is only looking for one field, but does the operation &lt;EM&gt;once per field per row.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Mar 2015 18:47:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190622#M14619</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-03-13T18:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190623#M14620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In addition to the points &lt;A href="https://community.esri.com/migrated-users/19932" target="_blank"&gt;Darren Wiens&lt;/A&gt; made, the rows returned by the update cursor are a tuple. In Python, a tuple is what's called an immutable object; it cannot be changed. You have to convert the row from a tuple to a list before you can change the values. Then you can pass the altered row list back to the cursor's updateRow() method (which accepts a tuple or list).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can also create the update cursor with only the fields you are interested in so you don't have to loop through all the fields unnecessarily.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code assumes the data type of the &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;length_val field is integer. It also assumes that if &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;total_length was a string, that it would never have more than one number.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;aoi_fields = ["total_length", "length_val"]
with arcpy.da.UpdateCursor(aoi_table_gdb, aoi_fields) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowList = list(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if isinstance(rowList[0], int) or isinstance(rowList[1], float):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowList[1] = int(rowList[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif isinstance(rowList[1], basestring):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Pull out only the number from the string
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowList[1] = int(filter(str.isdigit, rowList[0]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowList[1] = None
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(rowList)&lt;/PRE&gt;&lt;P&gt;I used &lt;A href="http://stackoverflow.com/questions/26825729/extract-number-from-string-python" rel="nofollow noopener noreferrer" target="_blank"&gt;this thread&lt;/A&gt; for extracting the number from the string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively, you could use &lt;A href="http://resources.arcgis.com/en/help/main/10.2/0017/00170000004m000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Calculate Field&lt;/A&gt; to do this (instead of an arcpy.da cursor).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:35:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190623#M14620</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T09:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190624#M14621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a small note that update cursors return rows in a list not tuple&amp;nbsp; (search cursors return rows in a tuple), so you can skip that step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 01:19:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190624#M14621</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-03-17T01:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190625#M14622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome!&amp;nbsp; Thank you.&amp;nbsp; I'll give it a try.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 10:50:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190625#M14622</guid>
      <dc:creator>JohnSemanchik</dc:creator>
      <dc:date>2015-03-17T10:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190626#M14623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Outside of ESRI stack you can take care of the unwanted characters before converting to your gdb table.&amp;nbsp; This is just an example of reading the .csv and using string manipulation to remove the '&amp;gt;, &amp;lt; or ~ characters from the total_length field, then using the arcpy.da.NumPyArrayToTable method to get it back into ESRI landia.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The ztest.csv is just 3 cols and 3 rows for testing consisting of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: Consolas;"&gt;total_length,IntCol,TextCol
&amp;lt;999.99,999,Some Text
~111.89,123,Some more text
&amp;gt;1.42,321,Even more text&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import numpy
import pandas as pd

df = pd.read_csv('H:\ztest.csv')
df['total_length'] = df['total_length'].map(lambda x: x.lstrip('&amp;lt;&amp;gt;~'))&amp;nbsp;&amp;nbsp;&amp;nbsp; 
dfarr = numpy.array(df.to_records(), numpy.dtype([('total_length', '&amp;lt;f8'),('IntCol', numpy.int32),('TextCol', '|S25')]))
tab = 'in_memory\dfarr_tab'
if arcpy.Exists(tab):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(tab)

arcpy.da.NumPyArrayToTable(dfarr, tab)
with arcpy.da.SearchCursor(tab, '*') as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(row[0]) + " " + str(row[1]) + " " + str(row[2]) + " " + str(row[3])&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:35:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190626#M14623</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T09:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190627#M14624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Even though &lt;A href="http://resources.arcgis.com/en/help/main/10.2/018w/018w00000014000000.htm"&gt;the documentation says tuple&lt;/A&gt;, it does return a list. Thanks for the clarification!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 15:45:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190627#M14624</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-03-17T15:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190628#M14625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If there is no chance that floats are involved, the &lt;SPAN style="font-family: courier new,courier;"&gt;str.isdigit&lt;/SPAN&gt; method can be used like you already tried.&amp;nbsp; Instead of type checking for &lt;SPAN style="font-family: courier new,courier;"&gt;int&lt;/SPAN&gt;, &lt;SPAN style="font-family: courier new,courier;"&gt;str&lt;/SPAN&gt;, or &lt;SPAN style="font-family: courier new,courier;"&gt;unicode&lt;/SPAN&gt;; you can just cast the field as a string and process it like a string.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;row[3] = None
if row[17] is not None:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[3] = int(filter(unicode.isdigit, unicode(row[17])))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If a &lt;SPAN style="font-family: courier new,courier;"&gt;float&lt;/SPAN&gt; could show up in the string fields, you could go with a regular expression approach.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;row[3] = None
&amp;nbsp;&amp;nbsp;&amp;nbsp; f = re.findall(r"[-+]?\d*\.\d+|\d+", unicode(row[17]))[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; f = float(f)
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[3] = int(f)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above regular expression is abridged in that it doesn't capture scientific notation, exponents, etc....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a good discussion on extracting floats from Python strings over at Stackoverflow:&amp;nbsp; &lt;A href="http://stackoverflow.com/questions/4703390/how-to-extract-a-floating-number-from-a-string-in-python" rel="nofollow noopener noreferrer" target="_blank"&gt;How to extract a floating number from a string in Python [duplicate].&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:35:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190628#M14625</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T09:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190629#M14626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/48550"&gt;Blake T&lt;/A&gt;, sorry to harp on this, but I'm not seeing the reference to the update cursor returning rows as a tuple. There are a few places that may take a tuple as input (e.g. fields), and outputs some properties as tuples (e.g. SHAPE@XY), but not rows. Perhaps you're thinking of the tuple row returned by next(), but this is hardly ever used anymore.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 16:42:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190629#M14626</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2015-03-17T16:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190630#M14627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, I was looking at the return value for the next() method. I see the second second sentence at the very beginning clearly says:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Returns an iterator of lists.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;But down at the bottom under the Method overview for next(), it says:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Returns the next row as a tuple.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I tested both the next() method and just iterating through the whole cursor in a for loop and both give the row as a list (like you said). &lt;STRONG&gt;Esri's documentation for the next() method is just wrong.&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 16:51:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190630#M14627</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-03-17T16:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190631#M14628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;They likely wrote the documentation for the Search Cursor first, and it is correct for that cursor because it does return tuples, and then someone got sloppy and didn't update the next() portion for the update cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Little mistakes like this happen, it is human nature, but what amazes me is how ridiculous it gets when you try to get Esri to correct them, i.e., open a Support Case, submit a documentation bug, wait for development to look at it (which could be months), and then maybe they will address it in a future version.&amp;nbsp; The software may, may, be agile but not the business processes!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 17:28:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190631#M14628</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-17T17:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190632#M14629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Type checking, e.g., &lt;SPAN style="font-family: courier new,courier;"&gt;field.type == 'String'&lt;/SPAN&gt;, might be the ArcGIS way but it isn't very Pythonic.&amp;nbsp; This is one of those cases where learning programming through ArcPy teaches less-than-idiomatic Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As the expression goes, and is summarized by &lt;A href="http://stackoverflow.com/users/14102/herge"&gt;@herge &lt;/A&gt;over at Stackoverflow (&lt;A href="http://stackoverflow.com/questions/152580/whats-the-canonical-way-to-check-for-type-in-python"&gt;What's the canonical way to check for type in python?&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;The &lt;STRONG&gt;most&lt;/STRONG&gt; Pythonic way to check the type of an object is... not to check it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since Python encourages&lt;A href="http://wikipedia.org/wiki/Duck_typing"&gt; Duck Typing&lt;/A&gt;, you should just try to use the object's methods the way you want to use them. So if your function is looking for a writable file object, &lt;EM&gt;don't&lt;/EM&gt; check that it's a subclass of &lt;SPAN style="font-family: courier new,courier;"&gt;file&lt;/SPAN&gt;, just try to use its &lt;SPAN style="font-family: courier new,courier;"&gt;.write()&lt;/SPAN&gt; method!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, sometimes these nice abstractions break down and &lt;SPAN style="font-family: courier new,courier;"&gt;isinstance(obj, cls)&lt;/SPAN&gt; is what you need. But use sparingly.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It is for this reason that I suggested type casting your integers to strings and then process them and your strings containing integers the same way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Mar 2015 18:38:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190632#M14629</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-17T18:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy - Check a field type and execute depending on the type</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190633#M14630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, you guys are awesome.&amp;nbsp; I've been combing through all of this and still running into a few issues, but this has been exciting.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blake, I tried to incorporate your code, but the values are all dropping through to None.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm going to look at the last few examples/ideas and see if I can get them hashed out.&amp;nbsp; I'd like to force the CSV to make the "total_length" column a string from the start, but unfortunately the CSVtoTable code I'm using runs a check on the data and makes the columns what the data are.&amp;nbsp; So if it's all integers then it makes it a "LONG" but if it's got a string in it then it defaults to TEXT.&amp;nbsp; We use it to convert other tables so I thought I'd incorporate it here.&amp;nbsp; (It's actually to solve a separate issue with this entire conversion, but in this case it was one step forward to take two back).&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks everyone for your help so far and when I have it figured out I'll post the result and mark the correct answer.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great weekend!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Mar 2015 16:16:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-check-a-field-type-and-execute-depending-on/m-p/190633#M14630</guid>
      <dc:creator>JohnSemanchik</dc:creator>
      <dc:date>2015-03-20T16:16:53Z</dc:date>
    </item>
  </channel>
</rss>

