Questions tagged [cursor]

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

Filter by
Sorted by
Tagged with
4
votes
2answers
319 views

Does arcpy.da.SearchCursor store the results in an array?

When performing a query like this: var = 2 with arcpy.da.SearchCursor(in_table="table", field_names=['c1','c2'], where_clause = '[c1]' + '=' '\'' + str(var) +'\'') as cursor: I've just simply been ...
0
votes
2answers
147 views

Passing conditional statements into arcpy.da.UpdateCursor

How do you pass conditional statements from a list into a data access module update cursor? I am using ArcGIS v10.3.1. a = r"...\Default.gdb\New_Shapefile" ConList = ["r[1] >= 1"] with arcpy.da....
1
vote
2answers
167 views

Arcpy SearchCursor reads csv field incorrectly

My code is: with arcpy.da.SearchCursor("txtFilePath", ["Field1", "lotsOFOthers"]) as cursor: for row in cursor: val = "%s" % row[0] ... non related code which selects a few values ...
1
vote
1answer
127 views

Using Arcpy UpdateCursor to make calculations based on multiple fields?

I'm new to Python. I would like to calculate field values for a specific 'IDF' based on values from another column. I have something like that: with arcpy.da.UpdateCursor(fc, ['IDF', '...
0
votes
1answer
35 views

Add Subtrack name attribute

import arcpy rows = arcpy.SearchCursor("E:/Arcgis/lx.gdb/testSUBorigin", "", "", "", "VEHICLEID A; TIME A") arcpy.AddField_management("testSUBorigin", "SUB", "TEXT") cursor = arcpy.SearchCursor("E:/...
0
votes
1answer
257 views

Arcpy InsertCursor.insertRow crashes ArcGIS after many (thousands) insertRow calls

I am looping over a quite large feature class (~5million records) While looping using a SearchCursor, I insert new geometries in a FileGeodatabase FeatureClass using arcpy.da.InsertCursor. The ...
0
votes
1answer
86 views

Select by attribute crashes ArcMap when used with search cursor, but not by itself

I have a script that I want to: run through polygons in a shapefile representing service areas > select each area > then select points from a different layer that fall within that selected polygon. (...
1
vote
1answer
46 views

Geoprocessing Service with Update/Insert Cursors caused multiple users to conflict?

I have a python script tool that I would like to publish as a geoprocessing service, but I'm not sure it'll work because this script uses multiple update and insert cursors to update database tables. ...
2
votes
1answer
145 views

Cursor to update feature class by location?

I am trying to update an existing field in a polygon fc with an existing field in a point fc. There is only ever one point fc located within each polygon fc. The field names in the polygon fc can not ...
4
votes
3answers
590 views

Looping if condition in ArcPy?

I want to use "Calculate field" based on the string in another field. I would like to loop if condition but something is wrong and I am little bit confused. I am super new in Python. Here is my ...
0
votes
1answer
79 views

Automating row selection and update of attributes in ArcPy? [closed]

I'm looking for a solution to automate a process I have found myself re-doing manually quite often. I have a dataset that consists of one column named "quarter" that is formatted "2018 Q1" (or Q3, or ...
0
votes
3answers
144 views

Converting arcpy.da script to arcpy.SearchCursor? [closed]

I am trying to learn python for ArcGIS. Currently on this tutorial exercise: https://www.e-education.psu.edu/geog485/node/191 import arcpy featureClass = r"C:\Users\A\Desktop\ARC\USA.gdb\...
1
vote
1answer
196 views

Using cursor in ArcPy gives TypeError: cannot concatenate 'str' and 'Polygon' objects?

I have been trying to use arcpy.da.seachcursor to rip through a datasets rows and use each in an intersect analysis like so: with arcpy.da.SearchCursor(in_feature, ['SHAPE@', 'NAME']) as cursor: ...
2
votes
1answer
90 views

Same SQL expression works with search cursor but not make feature layer

I need to get features in a File GeoDatabase feature class whose "fieldName" (string field) value matches the value of "strValue" (string variable). While I know there are features satisfying this ...
1
vote
2answers
346 views

Updating all attribute data in Feature Layer using ArcObjects

I have a layer with over 250,000+ features, and I want to update all the attribute data using ArcObjects and C#. I have written the code below and it takes around 3 hours to perform the update. Can ...
1
vote
0answers
27 views

InsertCursor error [closed]

I am trying to load data from a csv file (that contains well_id, x, y, elevation) to a shapefile. In my script, it adds fields from the csv field header that is not in the shapefile. It then updates ...
1
vote
1answer
520 views

Deleting row with cursor in ArcPy?

I am trying to delete field names where the field "FULL_NAME" = 1. What am I doing wrong here? I am not getting an error message, but nothing is being deleted from my file. I am not sure why ...
1
vote
2answers
61 views

Identifying small polygons that are inside larger bounding polygons within same feature class using ArcPy?

I've tried digging around for an answer to this question, but I've only been able to find answers that are either too broad or too different from my case, so here goes! Context: I have a layer of ...
-1
votes
1answer
51 views

Finding difference between populations from 1990 to 2010 and writing info to new field using ArcPy? [closed]

I am trying to write a script that finds difference but every time I use the information from instructor, I am getting an error, and getting nowhere... table: field one is: Area_name, field two is ...
1
vote
0answers
129 views

Looping through data to perform one to many join in ArcPy?

I want to join the attribute tables of two feature classes in ArcGIS and populate the fields from one table to another. This is a one to many join and there are duplicate rows of data in the join ...
1
vote
2answers
171 views

Populating multiple fields from string using Update Cursor? [closed]

I am trying to split up a comment field from a csv (or a dbf) into three different groups. The comment field is similar to this : Pa=68781/Rh=44.31/Ti=-7.56 AWEC Space Agency I want to split it up ...
1
vote
1answer
596 views

Error inserting multiple rows in a table [duplicate]

I am trying to insert values using the query below in a table insert into mytable (geom) values( (SELECT new_york_city_political_utm.geom FROM pointutm join ...
-1
votes
1answer
75 views

SQL query new feature within definition within loop of cursor

I am using ArcGIS 10.4.1.5686 and running code within ArcMap. I thought that this question is similar to SQL query new feature with loop, or even Using a for loop to execute a query in arcpy, but ...
1
vote
1answer
207 views

Sum Values for multiple unique field values

I am trying to modify an existing table that I can relate to a feature in Arcmap(v10.5). Currently, the table fields and values look like this: I would like to summarize the table. For each unique "...
-1
votes
1answer
255 views

Arcpy Update Cursor-Overwrite values in field based on CSV

I have a CSV file called Modifications. The header has two entries, Rental Object and Rental Object Name. The Rental Object is a string that has matching values in a FGDB feature class where the ...
1
vote
1answer
430 views

Updating Field Based on another Field using UpdateCursor?

I have a feature class in a FGDB called LeasePlans. It contains a field called Property_Ref. I then have a CSV file with a field called SAPNO. For the feature class, I need to check does the value in ...
1
vote
1answer
32 views

Arcpy Cursor error needs more specifics

When I us a cursor on a table and get a column that doesn't exist error as follows: with arcpy.da.SearchCursor(r'P:\csvExample.csv', ["ID", "example", 'long list of other headers']) as cursor: ... ...
0
votes
1answer
47 views

Changing different multi values based on the FID field using ArcPy?

Continually to Changing 1000 values in attribute table using ArcPy? Change specific rows in attribute table using Arcpy in ArcGIS 10.3 I try to change 850 different values in attribute table of ...
2
votes
2answers
393 views

Change specific rows in attribute table using Arcpy in ArcGIS 10.3

I need to change values in field "name1" (string field) in specific rows: 70-72 into "no land use" value. I search Arcpy code to do it. i red How to select specific row in attribute table using ...
1
vote
1answer
50 views

UpdateCursor won't update concatenated string?

I have a function I'm trying to incorporate in a model. It's supposed to check to see if one of two fields have a value and depending on the field with value calculate the other. The issue I'm ...
3
votes
1answer
79 views

Adding unique indexes which start with “A” go up to 99 (A1-A99) and then start again “B1” and continue up to B99 and so on? [closed]

i want to add unique indexes which have to start with "A" go up to 99 (A1-A99) once the 99 rows of finished it has start again "B1" and to continue up to B99, so this index system has to continue ...
2
votes
0answers
107 views

UpdateCursor doesn't give error until the next iteration ('NoneType' object is not iterable)

I have a string field within a GDB that does not accept all string values, giving a "The row contains a bad value" error. I have fixed the issue with InsertCursor (prompts user for new value), but can'...
2
votes
1answer
2k views

'TypeError: 'tuple' object does not support item assignment' when iterating through the rows of a layer

I'm trying to assign a value to the attributes of each feature of a feature layer. To do so I am just iterating through each row using 'arcpy.da.SearchCursor'. #Import geoprocessing. import arcpy #...
0
votes
1answer
50 views

write values to raster table

I am working with a .tif raster which has an attribute table. I can successfully add a number of extra fields, however I am having problems populating those fields. When I add the updateCursor part ...
1
vote
2answers
131 views

Performing row update within Select By Location based on field within selected feature class using ArcPy?

I am trying to select address points from address feature class within a selected zip code from zipcode feature class and populate the address feature class field "ZipCode" with the "Zip_Code" field ...
3
votes
2answers
785 views

Updating X and Y coordinates with UpdateCursor based on another shapefile using ArcPy?

I have two shapefiles: "broken_cities" and "us_cities." "us_cities" contains point data representing cities in the US, and the x and y coordinates are correct. "broken_cities" contains point data ...
-1
votes
1answer
32 views

Performing field calculation on new field using partial text from existing field via selection using ArcPy?

I am new to python and am having some issues with the following script. I want to select all features that have "State R%" in the field "ROADNAME" and populate another field called "Route" with the ...
3
votes
1answer
303 views

arcpy.da.SearchCursor not work when run the whole scripts in IDLE

I'm using ArcGIS 10.3.1. The code is running in IDLE of winpython 2.7 64bit. Here is a very simple code which intends to read a shapefile. import arcpy from arcpy import env env.workplace = "E:/" ...
0
votes
2answers
40 views

How to add N+1 second using ArcPy cursor for Time Field value?

I have a field that I would like to add one second on for each feature using field calculator and Python. My field name is ISSUEDTIME_NEW I want to start my time at 00:00:00 and add one second on to ...
3
votes
3answers
68 views

How to count rows of interest from a field in an attribute table using arcpy.da.Cursor?

How to count the number of records from a field 'COVER' that is neither 'woods' and neither 'orchards'? fileName = 'C:/gispy/data/ch17/parkCopy3.shp' fields = ['COVER', 'FID'] count = 0 . try: ...
0
votes
2answers
133 views

Reading geometry of a .gdb with large number of polygons [closed]

I've got a .gdb loaded into my ArcMap 10 that has about 9 Million polygons. I would like to get data from each polygon to include its geometry and certain fields from its row in the attribute table. I ...
3
votes
3answers
158 views

Update fields with geometry properties (X-coordinate and Y-coordinate of “true” centroid)

I've been trying to take the X and Y coordinates of the true centroid from a polygon shapefile I have called HamDA.shp and add such coordinates to two float fields called X and Y (with 12 precision ...
1
vote
1answer
214 views

Improving poor performance of ArcPy update cursor with ArcSDE and Editor? [closed]

I am using ArcGIS 10.5 in an ArcSDE environment. I have two tables, they are the exact same table schemas, but one is being edited and those edits are being pushed to the main table. I am a little ...
1
vote
1answer
56 views

Using update cursor to place points along line from .csv file?

I work for a utility company and we have a number of poles that did not have their GPS locations taken, rather where the line turns the GPS location was taken, and the span of each pole in between ...
2
votes
2answers
103 views

Populate fields based on selected objects using the updatecursor

How do I get my script to only populate fields on selected objects while editing on the map? # Importing arcpy import arcpy # Set the workspace environment arcpy.env.workspace = r'C:\Users\...
1
vote
1answer
50 views

Error Opening File?

I have searched the internet for a few hours now and have gotten to the point where I need to ask this. I am currently developing a code that will take a large subdirectory of .xlsx files, read them ...
1
vote
2answers
268 views

Error when creating Polyline from parsed table values: “CreateObject cannot create geometry from inputs”

I'm writing a script that parses GPS events from an SDE table to try and create lines in a feature class representing when street sweeper brushes were turned on. I'm appending the lat and long into ...
1
vote
1answer
34 views

Populate Null Records with Last Non-Null in List [duplicate]

I'm trying to develop a script that will iterate through a list of values within a FBGDB table/field and insert the last non-null value that was found into the ones that are null. Here's what the ...
3
votes
2answers
493 views

Writing Data Driven Pages' scale into driving layer's attribute table with arcpy

I want to write a scale value that is changing for every Data Driven Page (since using map extent best-fit so that each polygon in the driving layer would be whole in "its" exported map) to the table ...
1
vote
1answer
124 views

Convert WKT to Layer arcpy

I have a CSV file with number of records that have WKT Point geometry. I am bit lost on how to insert to this into a new point layer. Sample data from CSV file from GeometryItem Field: POINT (-...