Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cursor]

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

2
votes
1answer
31 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
12 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
33 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
51 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
40 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
23 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
26 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
29 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
32 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
19 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
51 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
20 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
65 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
36 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
52 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
85 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
56 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
66 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
34 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
27 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
19 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
35 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
13 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
65 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
43 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
27 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
43 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
36 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
55 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
108 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
43 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 ...
0
votes
0answers
28 views

Converting string 24hr date/time field values into new field with just 12hr time as string using ArcPy in ArcGIS Pro?

Without explaining all my reasoning for why we need to do this, I need to take a field that our GPS units create called "CreationDateandTime" and use the values in there to create a new "UID" field ...
1
vote
1answer
58 views

Getting for loop which stops after first one to iterate properly?

I originally asked UpdateCursor can't acquire lock, but can acquire lock in TestSchemaLock and got some help about why my code wasn't acquiring a lock. My new problem is that my code isn't fully ...
0
votes
1answer
42 views

Comparing Two Tables Using Arcpy

I'm trying to check the "fiberEquipment" table against the "material_cd" table and find instances where there are discrepancies. E.G -- Checking that "material_cd" 10785823 in "fiberEquipment" has all ...
3
votes
3answers
107 views

Comparing value with value from the next row

I have a table with two elements in this format: a b b a b c c b c d ....f g g f I have to analize if the second element is equal to the first element of the following row. If it's true, 1 is ...
0
votes
1answer
25 views

UpdateCursor cannot see new field added to feature class

I needed to add a new field to a feature class to act as a unique key, but when I run: fields = ['OID@', 'state', 'navkey'] ids = inspected_points #list of oid values oidfield = arcpy.Describe(points)...
0
votes
2answers
41 views

If field 1 > field 2 update field 3 in loop

I am trying to update the table above. What I want to do is if the values in the PMP fields are less than the Max fields update the check fields with PASS, if not FAIL. I started doing this trying ...
0
votes
3answers
72 views

Using ArcPy to ListFields inside SearchCursor?

The current code I have simply lists ALL fields in the feature class and seems to ignore my logic of if row[0] is not None: Why does it do this? fields = arcpy.ListFields('\\\\Bvweb104draco\\e\\...
1
vote
3answers
116 views

Search Cursor Return Field Name If All Rows Contain a Value

I'm trying to print the field name to a list if all rows in that field are not NULL. Here is the logic I have so far. fiberCable = r'Orlando\Orlando_FIM_prep\FIBERCABLE' list = [] with arcpy.da....
0
votes
1answer
31 views

Python to generate a different number of random points for features using iteration with tool parameter values in feature attribute table

I want to generate a certain number of random points in N number of zip codes. The number of points to be generated for each individual zip code is stored the attribute of the feature class of all ...
1
vote
1answer
59 views

ArcPy cursor get value in next row [duplicate]

I am trying to populate Field B based on the value in Field A and the next value in Field A. I'm having trouble with the syntax for getting the "next" value in Field A. Here is my current code: with ...
0
votes
1answer
15 views

Empty ShapeLength when running Insert Cursor for Polyline

I'm looking to create a new feature class using only selected data from a source feature class. I can get this to work but the ShapeLength field is 0 when I run this script and therefore the feature ...
0
votes
2answers
28 views

Displayng attribute text in layout Text element gives error: Error in setting text

I am new in Python scripting. I have a geodatabase with layer Test and this layer has field Name and Text element on layout named TEname. I am trying to show selected feature attribute Name value in ...
1
vote
1answer
293 views

Displaying attribute field value in TextElement gives AttributeError: 'list' object has no attribute 'text'?

I am new in Python scripting. I have a geodatabase with layer Test and this layer has field Name and Text element on layout named TEname. I am trying to show selected feature attribute Name value in ...
1
vote
1answer
70 views

UpdateCursor can't acquire lock, but can acquire lock in TestSchemaLock

import arcpy import os.path arcpy.env.workspace = "C:/Users/melis/Documents/HenryWork.gdb" arcpy.env.overwriteOutput = True buffer = "LS_buffer" landcov = "ForestLC_clip" #create search cursor to ...
0
votes
0answers
35 views

Write a script to create a new feature class and add the point objects of geometry to that feature class

The coordinates of the vertices representing the street Kochstraße in Erlangen are stored in a text file called Koord_Strasse.csv. Write a script to create a new feature class and add the point ...
12
votes
3answers
558 views

Deleting cursor used in SearchCursor within dictionary comprehension?

If it is best to open cursors using a with statement to ensure it is deleted, like so: with arcpy.da.UpdateCursor(fc,fields) as cursor: Then, if a cursor is used as the iterable in a comprehension ...