Is there any possible fetching row using Python script?
If I understand correctly you could use following script:
cursor = arcpy.UpdateCursor("testFC") gridDict = {} for row in cursor: print row.getValue("GridNo") gridNo = row.getValue("GridNo") if(gridDict.has_key(gridNo)): gridDict[gridNo] = gridDict[gridNo] + 1 else: gridDict[gridNo] = 1 name = "{0}_{1}".format(gridNo, str(gridDict[gridNo]).zfill(3)) row.setValue("Name",name) cursor.updateRow(row)
Make sure to correct the feature class path and field names as they are.
Thanks,
Mahtab
Thanking you so much. It was very useful.
I had created the Python toolbox. Is there any possible to hide our source in the Python toolbox.
There is no column which contains the "001", "002".
Yes, it might be useful to provide a screen grab (or equivalent) which shows the table that you have to see whether search/update cursors are needed or simply a field calculation with concatenation from existing fields, is needed.
If you have another column which contains the "001", "002" or perhaps just the number, you could probably just do a concatenation with the field calculator.
If you havn't got this second field, what governs the "001", "002" part connecting to "Grid1" etc?
Try searching for arcpy.da.UpdateCursor that will get you where you want to go
The last link is useful. But it is not clear my problem. I have attribute table that have Name and Grid no field. I have to update Name field using Grid no. For Example in the Grid Field (Grid1, Grid2, Gird2, Grid1, Grid1) so I have update Name field like as (Grid1_001, Grid2_001, Grid2_002, Grid1_002, Grid1_003). Kindly suggest me.
This is the direct link to "searchcursor"
http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/searchcursor-class.htm
There is a whole of lot of reading in the arcpy module, its classes and functions which should be read to put this in context.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.