<?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: Phython Script TypeError: range() integer end argument expected, got float in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028847#M25206</link>
    <description>&lt;P&gt;The&amp;nbsp;module run successfully after I fixed the field type from "float" to "integer".&lt;/P&gt;&lt;P&gt;Much Appliciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 20 Feb 2021 14:20:27 GMT</pubDate>
    <dc:creator>RIKAHARUYAMA</dc:creator>
    <dc:date>2021-02-20T14:20:27Z</dc:date>
    <item>
      <title>Phython Script TypeError: range() integer end argument expected, got float</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028834#M25202</link>
      <description>&lt;P&gt;Hello. I was trying to copy the shape features a number of times based on&amp;nbsp;the&amp;nbsp;numeric field by using the python code(The page referenced: &amp;lt;&lt;A href="https://community.esri.com/t5/geoprocessing-questions/copy-features-a-number-of-times-based-on-a-numeric-field-value/m-p/117358#M4021" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/geoprocessing-questions/copy-features-a-number-of-times-based-on-a-numeric-field-value/m-p/117358#M4021&lt;/A&gt;&amp;gt;@ XanderBakker)&lt;/P&gt;&lt;DIV class="user-profile-card"&gt;&lt;DIV class="info-container"&gt;&lt;DIV class="lia-message-author-avatar lia-component-author-avatar"&gt;&lt;DIV class="UserAvatar lia-user-avatar lia-component-common-widget-user-avatar"&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="user-info"&gt;&lt;DIV class="mini-profile-author"&gt;XanderBakker&lt;/DIV&gt;&lt;DIV class="mini-profile-rank"&gt;Esri Esteemed Contributor&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="links-area"&gt;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108" target="_blank" rel="noopener"&gt;View Profile &lt;/A&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;def main():&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import os&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_in = r"D:\forest\CHISAN\shp\L_koshibugawa.shp" # this one exists&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fld_count = "Count"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_out = r"D:\forest\CHISAN\shp\L_koshibugawa_duplicate.shp" # this one will be created&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sr = arcpy.Describe(fc_in).spatialReference&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # create the empty output featureclass&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; path, name = os.path.split(fc_out)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFeatureclass_management(path, name, "POLYLINE", fc_in, "SAME_AS_TEMPLATE", "SAME_AS_TEMPLATE", sr)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # insert the features into the output fc&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(fc_in, '*') as curs_in:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; flds_in = curs_in.fields&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; idx_cnt = flds_in.index(fld_count)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.InsertCursor(fc_out, '*') as curs_out:&lt;BR /&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 curs_in:&lt;BR /&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; cnt = row[idx_cnt]&lt;BR /&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; for i in range(0, cnt):&lt;BR /&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; curs_out.insertRow(row)&lt;/P&gt;&lt;P&gt;if __name__ == '__main__':&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;The module was able to run, but&amp;nbsp;I it got the error message below.&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "D:\forest\test.py", line 31, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;BR /&gt;&amp;nbsp; File "D:\forest\test.py", line 25, in main&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(0, cnt):&lt;BR /&gt;TypeError: range() integer end argument expected, got float.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Would be super nice if someone could lectuer me how to solve this problem.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2021 11:27:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028834#M25202</guid>
      <dc:creator>RIKAHARUYAMA</dc:creator>
      <dc:date>2021-02-20T11:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Phython Script TypeError: range() integer end argument expected, got float</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028835#M25203</link>
      <description>&lt;P&gt;I would say it's a simple as your COUNT field being of FLOAT type.&amp;nbsp; Check this, and if so, use Type Conversion to turn it into a integer:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for i in range(0, int(cnt))&lt;/LI-CODE&gt;&lt;P&gt;I've got no idea if the rest of the code is even valid as it gave me a headache.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2021 12:41:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028835#M25203</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-20T12:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Phython Script TypeError: range() integer end argument expected, got float</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028838#M25204</link>
      <description>&lt;P&gt;your field is incorrect&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fld_count = "Count"&lt;/LI-CODE&gt;&lt;P&gt;check to make sure that it represents a true count because if it contains decimal floats like &lt;STRONG&gt;1.5&lt;/STRONG&gt; you are going to have more issues.&lt;/P&gt;&lt;P&gt;As for formatting&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - GeoNet, The Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2021 13:30:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028838#M25204</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-20T13:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Phython Script TypeError: range() integer end argument expected, got float</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028843#M25205</link>
      <description>&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(fc_in, '*') as curs_in:
        flds_in = curs_in.fields
        idx_cnt = flds_in.index(fld_count)&lt;/LI-CODE&gt;&lt;P&gt;So I think flds_in is a tuple of the cursor fields, then the .index() method is used effectively as .index("COUNT"), to be able to grab the row[] by index (i.e. the value of the COUNT field at that row).&lt;/P&gt;&lt;P&gt;that leads me to think that the COUNT field is float type as per the error, although what is actually going on in the code and I have little idea.&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2021 14:07:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028843#M25205</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-20T14:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: Phython Script TypeError: range() integer end argument expected, got float</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028847#M25206</link>
      <description>&lt;P&gt;The&amp;nbsp;module run successfully after I fixed the field type from "float" to "integer".&lt;/P&gt;&lt;P&gt;Much Appliciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Feb 2021 14:20:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/phython-script-typeerror-range-integer-end/m-p/1028847#M25206</guid>
      <dc:creator>RIKAHARUYAMA</dc:creator>
      <dc:date>2021-02-20T14:20:27Z</dc:date>
    </item>
  </channel>
</rss>

