Hello. I was trying to copy the shape features a number of times based on the numeric field by using the python code(The page referenced: <https://community.esri.com/t5/geoprocessing-questions/copy-features-a-number-of-times-based-on-a-num...>@ XanderBakker)
XanderBakker
Esri Esteemed Contributor
---
def main():
import arcpy
import os
fc_in = r"D:\forest\CHISAN\shp\L_koshibugawa.shp" # this one exists
fld_count = "Count"
fc_out = r"D:\forest\CHISAN\shp\L_koshibugawa_duplicate.shp" # this one will be created
sr = arcpy.Describe(fc_in).spatialReference
# create the empty output featureclass
path, name = os.path.split(fc_out)
arcpy.CreateFeatureclass_management(path, name, "POLYLINE", fc_in, "SAME_AS_TEMPLATE", "SAME_AS_TEMPLATE", sr)
# insert the features into the output fc
with arcpy.da.SearchCursor(fc_in, '*') as curs_in:
flds_in = curs_in.fields
idx_cnt = flds_in.index(fld_count)
with arcpy.da.InsertCursor(fc_out, '*') as curs_out:
for row in curs_in:
cnt = row[idx_cnt]
for i in range(0, cnt):
curs_out.insertRow(row)
if __name__ == '__main__':
main()
---
The module was able to run, but I it got the error message below.
Traceback (most recent call last):
File "D:\forest\test.py", line 31, in <module>
main()
File "D:\forest\test.py", line 25, in main
for i in range(0, cnt):
TypeError: range() integer end argument expected, got float.
Would be super nice if someone could lectuer me how to solve this problem.
Thank you.