Questions tagged [cursor]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
25 views

Updating a field values based off of values in the same column

I am struggling with the concept of this code and am not sure if this is even something I can do. I am using a gdb with a feature dataset and a number of feature classes. I have a feature class "...
0 votes
2 answers
33 views

Deleting geometries in feature layer based on unique field values

I have a building feature layer for a county. Some parcels have more than one building, so the buildings in these parcels all have the same TMS number in the "TMS" field. I only want my ...
  • 121
1 vote
0 answers
50 views

Cursor script runs but not updating value

I have a script I wrote to use an update cursor to change any records in a feature class that has a field set to 'N' to 'Y'(coded domain values). I have ensured that the database connection file is in ...
  • 11
1 vote
0 answers
38 views

QGIS 3.22.10: problems with cursor, while writing a filter

I just remarked a problem in QGIS 3.22, I never had before. When I write a filter for a layer, then the cursor is several millimeters right of the place where I write. This makes it difficult to write ...
  • 319
-2 votes
1 answer
37 views

Time difference between two string fields with microsecond (or seconds) resolution using, Arcpy, datatime and UpdateCursor

I am trying to calculate (using Arcpy) the time difference between two fields that are in string data type and they have the following time format "YYY-MM-DD HH:mm:SS.sss" I have achieved ...
1 vote
3 answers
89 views

Auto Incrementing ID based on repetitive sequential ID and conditional parameter (ID based on two fields - arcpy) - Update Cursor

I am currently trying to generate an ID based on two conditions but I am having troubles to achieve that since I am failing to make my script work. Below the explanation and my code, I apologies if ...
0 votes
2 answers
43 views

How to use ArcPy SearchCursor, with a where clause, to return string formatted response with values

I am using an ArcPy Search Cursor to return the rows of a specified field within a shapefile. The for loop iterates through the feature class and returns the value of the rows in a formatted string as ...
0 votes
0 answers
70 views

Using Search Cursor results to Select Features by Attributes

I've been working on automating the workflow with Python for a product that I create on a weekly basis. Where I'm stuck now is I have a filtered point file which I want to use its attributes to filter ...
0 votes
2 answers
79 views

ArcGIS Pro Field Calculator: Updating each row with a minute added to previous time

I'm trying to update each row in my point shapefile with a date. What I want is the first row in my below table to read 7/14/2022 12:00:00 AM, second row to be 7/14/2022 12:01:00 AM, third row to be 7/...
0 votes
0 answers
37 views

SearchCursor is outside tuple range despite having multiple fields in the parameter

In the below script, I get an error on line that starts with insertRow that says IndexError: tuple index out of range. outputLocation = arcpy.GetParameterAsText(0) nullPntFc = arcpy.GetParameterAsText(...
0 votes
2 answers
34 views

Adding new value in new field using ArcPy

I have a polyline feature class with this attribute table: I need to get values without decimal numbers. I created a new field called "newLength" and tried to insert the new values (whole ...
  • 3,984
4 votes
2 answers
178 views

Comparing two sequential values in order to do an operation within sequence in another field

I have a shapefile representing points along a line. I have the downstream distance of each point on their respective line. What I would like to do is sequence the two fields in the attribute table ...
  • 51
0 votes
1 answer
32 views

Can't update row in Microsoft Access

I am trying to fill an empty column with unique number for every data, I use the following code: import arcpy my_input = [] column = "REGION_ID" column1 = "MUNICIPAL_ID" column2 = &...
-1 votes
1 answer
32 views

Transferring XY coordinates of point from one feature class to point in second feature class using ArcPy

I have a small list of points, testingPoints, that need their geometry (x and y points) transferred to points within a larger dataset, baseCentroids. The datasets share a common field POINTID to help ...
0 votes
1 answer
32 views

ArcPy error handling not picking up index error in script tool

I am creating a script tool and I am trying to handle a unique error message that is created when a csv file is not formatted correctly for the script. When I use the script standalone, the error is ...
0 votes
1 answer
29 views

Converting extent to int is changing value [closed]

I am iterating to get extents (XMin, XMax, YMin, YMax) of each feature (1 deg x 1 deg polygons). The values of the extents parameters are double precision and display to one decimal place. I need to ...
  • 63
0 votes
1 answer
32 views

Iterate through fishnet polygons for extents and update field

I am new to Python. I'm creating a Script Tool in 10.8.2 that generates polygons from Create Fishnet of 1 deg x 1 deg and a new field GEOCELL. I need to update field GEOCELL with the lower left corner ...
  • 63
0 votes
1 answer
60 views

ArcPy UpdateCursor for each row in a table using calculated values

I need to update the whole table with the new values in SI. However when I start a new cursor, the list of values seems to go away and I cannot update each row with its corresponding value. How can I ...
2 votes
1 answer
31 views

List Feature Classes and use Update Cursor to calculate date values

The basic premise is as follows: look in a folder and find all feature classes (within file GDBs), use a for loop to isolate feature classes one at a time and subsequently isolate date attributes, ...
  • 71
5 votes
2 answers
370 views

Python error in Update Cursor for ArcGIS: " 'int' object has no attribute 'type' "

I am fairly new to python and am trying to make a script that looks through an ArcGIS feature class and updates <null> values to 'tbd' or 99999 based on the field type (string, double/integer). ...
  • 71
-1 votes
1 answer
41 views

UpdateCursor increment reference in initial layer with ArcPy dosen't work [duplicate]

I use a function to increment the reference according to a condition I would like to update the reference in the initial table I do it with the following code but the line for the update doesn't seem ...
2 votes
0 answers
66 views

Compare two fields in different feature classes using ArcPy

I am trying to make an automation script to evaluate the distance and compare attributes between an incoming layer and another existing layer in the database. I made this script to say: If the ...
0 votes
2 answers
96 views

Select By Location and Calculate the Field Attributes Using ModelBuilder in ArcGIS Pro

I want to create a ModelBuilder tool that I can use to save my time when I need to populate a ward name into my asset layers. Here Ward is a Polygon feature layer and my asset layers can be point, ...
0 votes
0 answers
25 views

Why points created from polyline are not being placed on original polyline? [duplicate]

I have extracted coordinates of a polyline and created a list using FeatureClassToNumPyArray. Now i have written code to create points at those vertices. I have used the SR information of the polyline ...
0 votes
2 answers
80 views

Iterating over (selected) features by the same id

I have a feature class Test_NearestNeighbor_Code. This feature class has 7373 polygon features and a column/ field called osm_id. I want to do a calculation with all features that have the same osm_id....
  • 3
1 vote
0 answers
56 views

Geometry of the feature getting deleted after UpdateCursor

I am making a script which calculates numerous indices for each building. Here I am trying to get the area a 100 buffer around the building and the area of buildings intersecting with the buffer. Now ...
2 votes
2 answers
160 views

Refer to field name instead of index position in ArcPy cursor

With ArcPy cursors, we can refer to fields by using the field index position: with arcpy.da.SearchCursor(feature_class, ["ASSET_ID","ROAD_ID","CLASS","OWNER",&...
  • 918
0 votes
1 answer
173 views

ArcPy SearchCursor Error: "An expected Field was not found or could not be retrieved properly"

Using ArcPy, I'm trying to use a search cursor on a point feature class to populate a list. import os, arcpy # make feature layer in memory lyr_acq = "lyr_acq" arcpy.env.workspace = ...
0 votes
1 answer
35 views

When to Update Row within an Update Cursor that uses multiple if statements for different fields?

I have a model that requires a stupid number of conditional statements. The older version was utilizing feature layers, select by attributes, and Calculate fields many, many times. I rewrote it to ...
1 vote
2 answers
146 views

Finding max value in field using ArcPy

I have a table and I want to find max and min value in specified field (f1) with their names. I used this code but I only could print max and min values in f1. How can I print their names Like the ...
1 vote
1 answer
28 views

QGIS 3.16 cursor jumps out of screen when reshaping features

when I'm reshaping features my cursor sometimes jumps out of screen (see gif). This error occurs only when clicking on certain vertices but I can't find any pattern. When I save and restart QGIS it ...
  • 31
0 votes
0 answers
54 views

Iterating through shapefile and appending each row separately to existing shapefile

I am attempting to iterate through each row of a shapefile, run a process on it (finding the nearest point from each in_feature to the closest near_feature) and then appending each row to the ...
1 vote
3 answers
114 views

Updating first occurence of duplicate with lowest value in given field using ArcPy cursor

I have a few hundred GPS data points (saved in an ArcGIS Pro 2.9 file geodatabase) that logged simultaneously with different speeds. I am looking to write a Python script that will compare each row's ...
  • 133
1 vote
1 answer
122 views

Creating a buffer for each row in a shapefile

My input is a point shapefile with more than 500 features. I need to create separate shapefiles with a buffer of 15 kilometers around each feature (so the output will be more than 500 shapefiles with ...
0 votes
1 answer
44 views

All rows are being overwritten with last features value using arcpy.da.UpdateCursor

I am trying to populate fields based on objects. When trying to use Update Cursor it overwrites all of the row values with information from the last feature read. I am sure that I am meant to get it ...
2 votes
2 answers
184 views

Sorting field values within column in table using ArcPy

I have a feature class table named fcwells. It has a bunch of different columns but the column I need sorted is 0Meters. Many fields under 0Meters have multiple values separated by commas and it is ...
0 votes
1 answer
84 views

Inserting new point from XY Coordinates with field values using ArcPy

I am trying to add new point from table using XY coordinates fields to database. I can add point without fields, but when i try to add point with field values i can not do it. In SearchCursor ID is a ...
0 votes
1 answer
54 views

Updating cursor with values from txt file

I'm trying to update fields with updateCursor, but it doesn't work at all. I've worked with updateCursor before many times but this time - no success. I have a feature class (frameBoundaryBeforeAT) in ...
0 votes
1 answer
245 views

Replacing zero with no data in CSV file using ArcPy cursor

I have a CSV file with zero as some of the attribute values. Trying to use cursors and replace all zeros with no data or blank values. I am able to replace any numbers. But not able to update with ...
  • 1
1 vote
4 answers
121 views

ArcPy remove rows which don't match a list of substrings

I'm trying to use ArcPy to remove results of an OD cost matrix which don't have specific street names. I have the street names stored in a list and the OD results in a field called "Name" as ...
1 vote
1 answer
37 views

How to avoid default_value in field with ArcPy cursor (e.g. row[i]=None)

Some field in field_list has default_value=1 After executing the following code, such field is filled with the value «1», but normal fields are filled «Null». How could I avoid this for the field (...
0 votes
0 answers
48 views

Resetting ArcPy 'for' loop when using SearchCursor on shapefile

I am comparing the data in two shapefile Ex: Existing.Shp and UpdatedRecently.shp. Existing.shp files has 3110 Records and Updated.shp has 410 records total and 110 duplicated records from Existing....
0 votes
0 answers
140 views

Using ArcPy cursor to insert polyline

I'm trying to use an InsertCursor to write code where I insert a line segment from two points in the shapefile, but I keep getting a type error explained below import arcpy, os, traceback fc = 'C:/...
  • 69
1 vote
1 answer
67 views

Writing cursor to delete objects greater or less than particular FID

I have a couple of shapefile attribute tables I want to delete items greater than 10 FID using a cursor. My user arguments are the file path, FID, and the number that is the minimum number not to ...
  • 69
2 votes
3 answers
154 views

ArcPy Update a fields value as long as another field value stays the same

Problem: Using ArcPy in ArcGIS Pro 2.5.2. I want to increase a fields value by 1 as long as the value in another fields stays the same. In the picture below I show what I mean (filled in manually). I ...
  • 1,086
1 vote
1 answer
108 views

IndexError: list index out of range when using UpdateCursor

I am trying to update all values in column in a feature layer in ArcGIS Pro using arcpy.da.UpdateCursor, but I am getting the error: IndexError: list index out of range I am trying to update all ...
  • 23
3 votes
2 answers
179 views

Calling specific row using ArcPy search/update cursors

When working with search and update cursors, how do I call upon a specific row? In this example: import arcpy, os # I want to find a row where the FID is 10 # print value field in the row where FID ...
  • 69
0 votes
0 answers
310 views

Using ArcPy SearchCursor and InsertCursor to Search, Copy and Insert Rows in Same Table

I'm new to ArcPy and really coding in general. I have three fields titled "Subcat_1", "Subcat_2", and "Subcat_3" all being used to categorize different themes of survey ...
  • 1
0 votes
0 answers
106 views

InsertCursor throwing "error return without exception set"

I'm trying write data to an Enterprise geodatabase but it still throws error return without exception set (for clarification - error throws row cursor.insertRow(data). I have method: def ...
0 votes
1 answer
110 views

SearchCursor RuntimeError: Underlying DBMS error [ORA-00923: FROM keyword not found where expected]

I need load OBJECTID from remote DB but I'm still getting error: RuntimeError: Underlying DBMS error [ORA-00923: FROM keyword not found where expected] [SDEDO.E_EL_TU][STATE_ID = 22362] I don't know ...

1
2 3 4 5
20