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
1answer
35 views

Reading column line by line from table in geodatabase using ArcPy?

I have a table in a geodatabase. It looks like this: id table_na 0 1 ER_ASTENOT_ASTOTA 1 2 INT_ASTENOT_ASTOTA 2 3 ER_ASTENOT_ASTTOM It has more columns though. Can you tell me how ...
0
votes
3answers
105 views

Writing fields from point shapefile to text file using ArcPy? [closed]

I have the following script, trying to take a cities shapefile and create an exported text file that will list each feature in the text file with (I can't figure out where I'm going wrong): CityName1,...
-1
votes
1answer
86 views

Search Cursor Cannot open Feature Class [closed]

import arcpy pld3GDB = 'C:\\Users\\bro81520\\Documents\\ArcGIS\\PLDV3_SPC_ODN_315_25Sep.gdb\\PLDV3_SPC_ODN_315_25Sep.gdb\\WO_HIERARCHY' list = [] fields = ['VENDOR_WO_ID', 'NFID', 'ISFDA'] with ...
1
vote
2answers
294 views

Not Able to Pass Where Clause in SearchCursor in ArcPy

Can you please take a look at this snippet and let me know why I am not able to properly pass the Where Clause ('"[NAME_1]" = Ohio') in SearchCursor? import arcpy from arcpy import env def ...
0
votes
1answer
50 views

Updating empty field with calculated data using ArcPy?

I have a current script that calculates how many wells are in each county. Now, how do I update (fill in) the COUNTIES shapefile attribute fields of 'Well_Count' and 'Density' import arcpy arcpy.env....
0
votes
1answer
74 views

UpdateCursor not updating when run from PyCharm?

I have a script in ArcPy that iterates through a set of intersection points and determines if all intersecting streets have the same attribute value in the CROSSLTS field, and if they do, sets the the ...
0
votes
2answers
55 views

Arcpy UpdateCursor not Updating, but no Error Reported

Below is the code I'm using in an SDE GDB, on ArcMap 10.4.1: import arcpy # Variables inputAsbuilt = arcpy.GetParameterAsText(0) transmedia = inputAsbuilt + "\\Transmedia" structure = inputAsbuilt + ...
0
votes
2answers
51 views

Weird cursor issue

Lets say I have a temp layer made out of selected items from another layer and I am trying to look through 2 attributes in that layer with searchCursor: union_test = "C:/Workspace/Sandbox/...
1
vote
1answer
41 views

Sorting by shape token in ArcPy cursors?

I have a script that uses the sql orderby parameter to sort my arcpy cursors by a user defined field or fields and deletes duplicates, but keeps the duplicate with the highest value. I'd like to be ...
1
vote
1answer
142 views

RuntimeError: General function failure when running arcpy.da.SearchCursor

I have a script that was previously working but just started throwing an error out of the blue. Here is the traceback: Traceback (most recent call last): File "<ipython-input-68-be384b1c4968>...
1
vote
3answers
217 views

Using arcpy.da.UpdateCursor to updateRow gives RuntimeError: row contains bad value?

I have a fishnet grid (polygon SHP), and all the little fishnets have a "Zone_ID." There are generally several dozen to a few hundred fishnet polys associated with each Zone_ID. I'm trying to number ...
0
votes
1answer
69 views

SearchCursor not reading the last row

Let's say I have a layer made up of pre-selected features from another layer: selects = arcpy.SelectLayerByAttribute_management (S_FIRM_Pan, "NEW_SELECTION", "DFIRM_ID = '{}'".format(fipC)) If I get ...
0
votes
0answers
39 views

Updating Polygon only on multiple selection, not single, using ArcPy?

I have a script that selects all addresses within a polygon (also multi polygons), and then sums a column "Anzahl" from those selected addresses. The Sum is then written to the Polygon in the column ...
1
vote
1answer
29 views

Using ArcPy SeachCursor in Point SHP to define new variable made of point coordinates?

I have a polyline, and I am trying to extract the endpoint x,y coordinates to define them as variables. For example, if I want to define as PtA = 551799.478099, 3762853.77587; and PtB =561687.918363,...
2
votes
1answer
147 views

Calculating a field base on another field script

I have a arcpy.script that calculates another field based on an existing field. However I only want the field to populate a value if the existing field is a specific value. This would leave some field ...
0
votes
1answer
39 views

Detecting failure of Data Access Insert Cursor?

I have data that I have now determined is failing because the underlying Oracle table has a unique constraint that fails. When a duplicate row is inserted there are no exceptions thrown - no way ...
1
vote
1answer
47 views

Name attribute in a new field as a function of attribute in another field

I have table with a field containing attribute names in another language (oldname1, oldname2,...). I want to create a new field in which I can add (with field calculator) the translated name of each ...
0
votes
1answer
189 views

Style OpenLayers 3 cursor when drawing shapes

I have a feature that allows a user to draw a square or rectangle on an OpenLayers map. I would like to change the style of the cursor. The cursor is, by default, a blue circle. I would like to change ...
2
votes
2answers
105 views

Breaking up geodatabase table with more than 1000 records into multiple tables with 1000 records maximum in each using ArcPy?

I'm trying to use the arcpy.da.SearchCursor and arcpy.da.InsertCursor objects to scan through a table with more than 1000 records and create multiple geodatabase tables with a maximum of 1000 records ...
1
vote
1answer
137 views

Comparing a list from an arcpy search cursor to a list from a CSV file

I'm attempting to compare entries in a CSV file to entries in a geodatabase using a search cursor through arcpy. I'm not sure if this is the best way to go about a comparison against these two ...
1
vote
2answers
205 views

Joining several fields into single field using ArcPy?

I'm trying to create this result (see the first row below): using this data (see the selected row): As you can see, the two vector tables have a common field, that relate themselves, the input is "...
-2
votes
1answer
53 views

Update Cursor ArcPy based on a separate feature class [closed]

I am building a script that appends features from one layer to another however some of the fields that I need populated are not titled the same which causes them to stay null. How can I set the row in ...
1
vote
1answer
127 views

Using a dictionary to update one attribute based on another

I need to update a large dataset based on information in an Excel table. I figured the easiest way to do this would be using a dictionary I can fill out from the Excel table and run it on a feature ...
1
vote
1answer
224 views

Comparing multiple field values of two feature classes using ArcPy?

I incorporated the following code into my script from Comparing field values of two feature classes using ArcPy? and it works great but I also need to compare two other fields values (i.e. YEAR & ...
0
votes
0answers
23 views

Data type error in UpdateCursor [duplicate]

My issue is that I am getting an error statement that states the following: row[0] = row[2] / row[1] * 100 TypeError: unsupported operand type(s) for /: 'NoneType' and 'float' Here is the ...
0
votes
1answer
182 views

Why does using next() with an update cursor nested inside a Search cursor yield such weird results

I did this: with arcpy.da.SearchCursor( in_table = in_table, field_names = '*', where_clause = "", sql_clause = (None, "ORDER BY date"))\ as ordered_cursor: with ...
1
vote
1answer
114 views

Using SearchCursor to round in ArcPy?

I'm pretty novice at Python and I'm trying to employ a search cursor to round a field in a table in ArcGIS. cursor = arcpy.SearchCursor(table,'', '', 'Distance') for row in cursor: round(cursor,...
-2
votes
1answer
77 views

Calculating total numbers of wells that fall into each county of table using ArcPy?

Directions: For each county calculate the total numbers of wells that fall into that county, and update the county table with the total count. This is the code I have so far. Problems: The ...
1
vote
2answers
65 views

For loop to calculate percentages using update cursor

I'm trying to run a for loop to calculate acreage percentages for a shapefile. I've converted field1 and field2 to float. I'm having trouble executing the CalculateField tool using the updateCursor. I ...
2
votes
1answer
37 views

How should I use features when iterating a feature class with a cursor?

I'm iterating through all the features of a feature class (polygons) and I don't think I understand very well what each row is exactly. See example below of what I'm trying to do with arcpy: ...
0
votes
1answer
32 views

Batching field calculations and feature classes in feature dataset using ArcPy?

I'm working on writing a script that will calculate facility ID's for feature classes in a feature dataset. Is there a way to do this without making feature layers and doing select/field calculate ...
0
votes
1answer
167 views

Verifying if user input as value exists in column using ArcPy?

I am trying to verify whether a value inserted by a customer exists in the field. import arcpy import os import sys #Set the work space arcpy.env.workspace = "Y:\Milad\GeometricNetworkAnalysis" path=...
0
votes
2answers
44 views

Writing ArcPy code to return total footage of pipe for each material types?

I am trying to write a Python script that will return the total footage of pipe for each material type. I got as far as getting the total footage for all of the pipes, I am just not sure where to go ...
1
vote
1answer
89 views

Using Update Cursor to Calculate Field from List of other Values

I'm working on a script that will use a predefined list of strings to calculate the value of a new field. The idea is this: if the value of field 'EF_Type' is equal to the value of a string in the ...
0
votes
2answers
61 views

Iteratively Updating Just Bottom Row in Table using ArcPy?

I see lots of examples of updating a specific column down ALL rows of a table, for example: with arcpy.da.UpdateCursor(Input_Layer, ['Column_1','Column_2']) as cursor: for row in cursor: ...
1
vote
4answers
118 views

ArcPy SearchCursor Loop Only Executes Twice

I'm trying to loop through a set of lines and select points within .25 miles of them. I just need the count, so I'm trying to put the results into a list I can print out. The relevant code is below. ...
1
vote
1answer
194 views

Running ArcPy geoprocessing tools on cursor rows?

I have a script using a Search Cursor to iteratively make copies of individual features for use as inputs in a geoprocessing tool, e.g., fc = <feature class> arcpy.MakeFeatureLayer_management(...
1
vote
1answer
46 views

Updating Field using similar Field w/ Update Cursor: Field does not populate

I'm pretty new to scripting with Python. My code is intending to iterate through a list of feature classes within a GDB, creating the fields EF_Type and EF_Group, then calculating the field. The ...
1
vote
1answer
143 views

UpdateCursor if loop references next row in field [duplicate]

I am trying to populate a unique identifier field "STD_ID" using arcpy.da.UpdateCursor. The identifier would be an iterative 1,2,3 and would reset the iteration based on region ID in which the ...
1
vote
1answer
48 views

Can't assign a numeric value to a field that is set to <Null>

Within a feature class there's a number of records with a specific field (type double) set to . I've set up a cursor to assign those value a numeric number. However, I am getting an error. This is ...
0
votes
0answers
55 views

How to edit attribute with my result from the count

I need this to loop through all the OBJECTID for the Fitting layer. Then it get the count for every line feature touching it. Now I'm at the point where I need the attribute table to be edited with ...
2
votes
1answer
53 views

Adding field which, depending on direction field value, gets value from previous or next row/feature in another field?

I am having difficulty getting to grips with arcpy and cursors. What i aim to do is the following: Depending on the direction specified in Test I wish to update the Target field. If it is forward, the ...
2
votes
3answers
71 views

exclude rows from table

I am new to arcpy, and I am trying to write a code in order to extract just the records containing specific attributes. This code gives back an empty table. What am I doing wrong? import arcpy arcpy....
3
votes
3answers
281 views

Deleting selected rows in ArcPy?

I am new to ArcPy and I am trying to write a code to select specific rows from a shapefile. I wrote this code, which gives back: Parsing error SyntaxError: invalid syntax (line 3) Any suggestions ...
2
votes
2answers
320 views

Use UpdateCursor to update a field based on text in other field

I am trying to find the correct syntax for the UpdateCursor where I look for part of a text from another field. I have many values of PCD zoning codes (PCD 03, PCD 04, PCD 05, etc). I want to ...
2
votes
2answers
68 views

Coding issue - trying to update single FC using SearchCursor & UpdateCursor

Fairly new to python and I have a issue with writing new values to an existing text field in a feature class/shapefile. I want to update the existing text values by taking the Shape@ geometry of the ...
1
vote
2answers
59 views

Comparing Object Fields to a couple million rows with a SearchCursor from arcpy

I'm new to GIS. I'm using arcpy.da.SearchCursor to read from a SQL server, and when I read through the first table I create objects ~350,000 of them. cursor = arcpy.da.SearchCursor(...
1
vote
1answer
217 views

keep getting error while trying to insert row using insert-cursor

I'm trying to add a text file of points to a feature class using insert-cursor and I can't seem to figure it out. I'm new to python and arcpy so this is a little confusing for me. the error message I ...
2
votes
2answers
148 views

Using two Search and Update cursor pairs on the same feature class

I've been working on this code for about 3 days and all of my time has been spent trying to understand why I can only execute the deleteRow() method on the first pair of cursors. The idea is that a ...
0
votes
1answer
21 views

Sending value in Entry widget to Feature Class via ArcPy insertCursor?

I have a python script that is adding a record to a feature class and it is working correctly. However, I now want to allow the user to enter the record details via Entry boxes. The record is being ...