Questions tagged [cursor]

Cursors are used by database programmers to process individual rows returned by database system queries.

Filter by
Sorted by
Tagged with
0
votes
0answers
26 views

Using Select by Attribute with multiple layers in ArcGIS Desktop? [on hold]

I'm using ArcGIS Desktop 10.3 and am trying to find "Bangalore" in a field named "City" and I want to find and select for all layers. I do not want to go into every single layer for find and select. ...
2
votes
1answer
122 views

Using ArcPy to insert new data into shapefile without editing it?

I want to insert new data into a empty shapefile. I have an array with the fields values of each row and I use InsertCursor to add these data to my shapefile. When I run the code if the shapefile is ...
3
votes
1answer
40 views

Insert Cursor Not Filling XY Field

I have a table with a set of original XY values and a set of new XY values. I want to create new points of the new xy's using the insert cursor. My code updates the ID and Sp row but not the XY row. ...
1
vote
2answers
33 views

Use ArcPy for finding value throughout all fields and export to new layer

I need to find a way to find a specific value in the attribute table and then export all rows with said value to a new feature class. Below is the code that I have managed to come up with (using ...
0
votes
0answers
20 views

RuntimeError: Objects in this class cannot be updated outside an edit session

I recieved this error: RuntimeError: Objects in this class cannot be updated outside an edit session while runnng this code: # import modules import arcpy import random from arcpy import env ...
1
vote
2answers
45 views

Transferring Data From One Table to Another Using Multiple Keys in ArcPy?

I have data in one field and I want to transfer it to a specific field in another table based on specific keys Such as ID, road_type and veg_type. My original table looks like this ID Road_Type ...
3
votes
2answers
44 views

Inserting field values in table?

I am trying to insert Field Values to an empty table. My code by so far: arcpy.CreateTable_management(r"C:\Users\esri\Documents\ArcGIS","test") arcpy.AddField_management("test","total","LONG") arcpy....
1
vote
1answer
28 views

UpdateCursor: value from different rows (ArcPy) [closed]

I am new to ArcPy. I have an attribute table with the following columns and fields I want to fill up the column Combined as follows: If number contains 2 categories, "combined" will be A,B. If ...
2
votes
2answers
51 views

Update 1 random value in a group of values

I have an attribute table with a date field and a random field. The date field has three different times for each day. I need to input a '1' in the random field for one of those three times in each ...
0
votes
1answer
38 views

How can I insert degree symbol to attribute table in feature class?

I am trying to insert a bearing string into an attribute table, I want the string to look like this -> S 58°15'31" W , but what I am getting in the table is this -> S 58°15'31" W The code I am ...
0
votes
1answer
38 views

arcpy.da.UpdateCursor not updating [closed]

The script will run without error, but the updatecursor at line 123 does not update the table. the addmessage before and aftr the loop shows right numbers but update does not seem to work. # -*...
1
vote
1answer
24 views

Add date and time to attribute table using ArcPy insertcursor

ArcPy under ArcGIS Pro 2.3.2. I am adding a Python datetime.datetime object to a shapefile attribute table using an arcpy insert cursor. The problem is that when I add the datetime instance, the date ...
0
votes
1answer
40 views

Using Cumulative Geometry Calculation to Add Field in ArcPy

I am using Desktop 10.6, Basic license, Spatial Analyst, Python 2.6, 2019 AD. I have 4 overlapping features in a polygon feature class. I'd like to sort the features by the depth field, calculate the ...
0
votes
1answer
50 views

Using Editor tab Clip function in ArcPy?

I am using ArcGIS Desktop 10.6, basic license, Spatial Analyst, python 2.6, 2019 AD. I have a polygon feature class with representing a lake, with multiple features overlapping (all in the same ...
2
votes
1answer
25 views

Updating field in geodatabase table depending on other field using ArcPy?

I have a table in a file geodatabase that has "FieldA" and "FieldB". I want to update FieldB with one of two values, depending on if there are one or more records with the same value of FieldA. ...
0
votes
1answer
48 views

Fetching data from ArcGIS attribute tables using ArcPy? [closed]

I want to fetch/extract data from ArcGIS attribute tables (to set some temporal series) using Python. Because of the structure of my tables and their disposition, I thought of using the "division" ...
2
votes
1answer
35 views

Updating arcpy.Array() syntax from Python 2.7 to 3.6.6 for ArcGIS Pro 2.3?

I was working through an exercise designed to teach basic Python skills in ArcMap using Python 2.7. The file below consists of 34 pairs of x,y coordinates. The script creates a new empty polyline ...
0
votes
0answers
13 views

Getting Error for Search Cursor in Arcpy module

I am trying to use Search Cursor on Data. Following code is running for Numeric field without any error. cursor=arcpy.da.SearchCursor("Wells","*",""""Depth"=30""") for i in cursor: print i[1] ...
0
votes
0answers
37 views

Python Code to return column data in multiple feature classes and gdb's

>>> import arcpy ... in_table = r"K:/MAPPING/PA/LEIDY/REPL/0188_18/MDL/GIS/MASTER/0188_18.gdb/DP_Centerline" ... with arcpy.da.SearchCursor(in_table, ["last_edited_date"]) as scursor: ... ...
0
votes
3answers
56 views

Using field in place of value in WHERE clause of arcpy.da.SearchCursor()? [closed]

I am developing an ArcPy script in ArcGIS Desktop 10.7 and using a file geodatabase feature class. I have a field called facility_id. I have tried using this field as a string field or as an integer ...
0
votes
1answer
43 views

UpdateCursor with SelectByLocation for multi polygon

At the end of this script, I have an UpdateCursor that updates the PLOTS field in the Timber_Type_Polygon with the amount of plots that are within the Timber_Type_Polygon. There's 3 polygons within ...
0
votes
1answer
29 views

What are row.Object and row.Text in Arcpy?

I'm trying to understand an arcpy script and I'm stuck with the following lines: cur = arcpy.SearchCursor(Tabelle) row = cur.next() while row: text1 = row.Objekt text2 = row.Text As far as ...
-1
votes
1answer
29 views

Using Field Calculator for subtracting values with same ID in ArcPy? [closed]

I have a line shapefile that used for some calculation. One of the calculation is subtracting values with a same group ID. The shapefile has a filed called LineID that consists of 2 lines with Side 1 ...
0
votes
1answer
32 views

ArcPy updating fields from another table

I'm trying to update missing values in one .shp from another .shp. I'm using SelectLayerByLocation to identify the properties which lie within the boundaries of a suburb and then using a UpdateCursor ...
0
votes
1answer
33 views

ArcPy Update Cursor Not Populating Field?

I recognize similar questions have been asked but I have yet to see what my code is lacking in any of their answers. I am trying to use the code below to periodically update attributes in a Feature ...
1
vote
0answers
52 views

Making ArcPy script quicker? [closed]

The script below is used to update a shp which is missing values from another .shp using a spatial reference. It's taking about 19 minutes to run through ~53,000 rows. Any ideas on how I can make it ...
1
vote
1answer
20 views

Extracting field value from Info table( .info ) in ArcGIS

I am working on a Python snippet try to use arcpy.da.SearchCursor() to extract value of certain field from a Info Table which generated by executing arcpy.Statistics_analysis().Here's my code: arcpy....
0
votes
1answer
64 views

Taking data from a CSV file to create points on a shapefile [closed]

I am trying to import data from a CSV file and write a script that will generate points on a new shapefile. I am running into issues for when I try to update the InsertCursor. I get an error of "not ...
0
votes
1answer
24 views

UpdateCursor giving ValueError: need more than 1 value to unpack?

I am writing a script assigning the ADMINAREA value to the empty LOCALITY fields from TWB_Suburbs to TWB_Property layer. I am getting: ValueError: need more than 1 value to unpack Is anyone able ...
1
vote
1answer
26 views

Using Update Cursor to categorize crash ratios? [closed]

I'm new to coding and I need to somehow use an Update Cursor that I can convert the rates of crashes in a block group into 3 separate categories. The crash rate is the difference between the number ...
0
votes
1answer
71 views

Parsing CSV data and updating a dictionary and creating a polyline

I am a little stuck on my code. I am new to Python and am learning as I go, but have usually been able to figure it out till now. The code was working up till I put the dictionary part in and now ...
2
votes
1answer
37 views

Checking field is empty and then adding new row with zeros?

I created a table with three fields but there are no values in these fields. Here is the screenshot of these fields. I want to add a new row with zeros for all these three fields. Here is my code. ...
1
vote
0answers
60 views

Accessing additional CAD annotation fields

I'm trying to read certain values from the annotation layer of a CAD file (MicroStation.dgn). It seems like for certain entities (Cell) the text isn't stored in the field 'TxtMemo' or 'Text'. When I ...
0
votes
0answers
23 views

Compare Specific Points of Line Features in two Feature Classes using FeatureClassToNumPyArray

I am looking to compare the first and last point between features in two different feature classes. The features share a common ID. My thought was to create two arrays via FeatureClassToNumPyArray. ...
4
votes
1answer
88 views

Update Cursor skipping last row?

I have created a python function within field calculator to calculate the time difference between a timestamp (yyyy-MM-dd HH:mm:ss) in a row and the row after (the interval field in seconds). I have ...
1
vote
2answers
65 views

Search Cursor to apply summarize statistics to all the row in a column

I use the following logic in ModelBuilder to get a result as seen below: A feature class has a Column with the name "Value" which is passed through to the Summary Statistics Tools which calculates ...
0
votes
2answers
89 views

Switching from Nested Search Cursors to Dictionaries

I'm working with a table that has in excess of 800K records and my method of using nested cursors is not practical. I've been reading and it looks like I should switch to dictionaries, but after much ...
0
votes
2answers
53 views

Using cursor.next() is resetting “row in cursor” causing it to skip every other row

I'm trying to update a column based on the value in the next row, but cursor.next() is giving unexpected behavior. When I identify the next_row using cursor.next(), it is resetting my row in cursor! ...
1
vote
1answer
52 views

Add point to shapefile / “IndexError: tuple index out of range”

I'm trying to add to a shapefile a point that is a (x-y) distance away from another point (city). None of the cities in the shapefile have x-y coordinates in the attribute table; I've added them for ...
-1
votes
1answer
20 views

Insert a point into feature class based on another point [arcpy] [closed]

My assignment is to insert (using insertCursor) a new city at 0.02 decimal degrees east and 0.03 decimal degrees south of another city. The cities shapfile did not originally have x-y coordinate ...
1
vote
1answer
44 views

ArcPy rollback update / insert cursors if error occurs

Is it possible to rollback an update made with an update cursor or an insert made with an insert cursor if an error occurs? I need to go through a feature class and break numbers up into 100 groups. ...
0
votes
0answers
16 views

Skip locked rows for editing using ArcObjects?

Can I lock a row so that the cursor does not bring it because it is in use by another cursor ? ITable table=GetTable(); ICursor crntCrsr=null; ICursor secondCrsr=null; crntCrsr=table.Search(filter,...
1
vote
1answer
72 views

How do I insert a list of values into individual rows using Python?

I have a dataset that contains a field with a range of numbers (e.g. 1, 2, 3-6) as well as other fields. I've used python to expand the range field into discrete numbers (e.g. 1, 2, 3, 4, 5, 6) stored ...
1
vote
1answer
45 views

Deleting row using ArcPy cursor?

I am new to python ArcPy. I am trying to delete identical points in feature class. the code is below: >>> import arcpy >>> fp=r"D:\NOCAS\TEMP\Belgum transistion.gdb\transistion\...
1
vote
1answer
34 views

Trying to add a value in the second row of a table

I am trying to add a specific value to a cell of the second row of a feature-class-table. Doesn't work with my code: #First row rows = arcpy.InsertCursor(tb_value) row = rows.newRow() ...
2
votes
1answer
45 views

Why is data from Collections.DefaultDict(list) a string?

While creating a defaultdict(list) containing street names, x and y coordinates, my x and y entries are converted to strings. This prevents me from doing calculations on them. I've been looking around ...
0
votes
1answer
44 views

arcpy.da.SearchCursor storing data in a list with a query

I am currently working with a database that hold street names, x and y coordinates and many more fields. I would like, through a search cursor, to store the x,y coordinates in a separate list for ...
3
votes
2answers
61 views

ArcPy UpdateCursor deleting duplicate records?

I am working with .dbf files. I have two columns of data that have duplicates. A column of parcel numbers with duplicates and a column of letters that are duplicated. I want to delete all parcel ...
1
vote
4answers
147 views

Retrieve last Row and specific field values with SearchCursor

I have a shapefile from which I want to retrieve the last row values for specific fields to use them as input in a tool. So far this is what I have which does not work. length=int(arcpy....
0
votes
1answer
73 views

Update attributes with arcpy.updateCursor and updateRow

I need to update attributes with arcpy.updateCursor and updateRow based on a list of service numbers, but I can't even get one row to update. This is my beginner code. df= r"GAS FEATURES\SERVICE ...