Hi Friends,
kindly attached .gdb, example excel sheet, and image for your reference. I want to create a unique id 001 for each batch have 30 point feature, next 30 point feature I want to create 002....etc like that
I want to create at a time any arcpy code available please help me.
I want to create a unique at a time like 001,002,003....etc each batch has 30 point features see the example below.
Thanks
Santhosh
I just used a Notebook and tried this code and it worked. A little different from the original code that runs in Spyder:
intCurrentBatch = 1intStartNumber = 1intBatchSize = 10intBSAfterFirstTimeThrough = intBatchSize - 1with arcpy.da.UpdateCursor(fc, fields) as cursor:for row in cursor:if intStartNumber <= intBatchSize:row[0] = str(intCurrentBatch).zfill(4)cursor.updateRow(row)intStartNumber = intStartNumber + 1else:intStartNumber = 1intCurrentBatch = intCurrentBatch + 1row[0] = str(intCurrentBatch).zfill(4)cursor.updateRow(row)intBatchSize = intBSAfterFirstTimeThrough
Image of Notebook. Keep in mind that indentation level is important.
Results
There might be more elegant ways of doing it but this worked for me. I wrote this in Spyder:
result in my test data:
Hi KimGarbade,
Can you share with me the above code? Exactly I am looking at the above result.
Sorry, I'm not at the computer I wrote that code on (that was my home PC). So I don't have a text version of the code here (at work), but the code I used was in the first image above. There are no lines of code either above or below the lines shown (no lines below line 27).
I wrote the code in Spyder, which is a third party Python editor, but it should work in any python environment that supports arcpy.
when I was using the above code it's showing the error message. can you see the below image for your reference
Finally, I got the Result of my data Thank you so much for your help.
Result in my data below
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.