Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
3answers
52 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\\...
0
votes
0answers
33 views

ARCPY UpdateCursor using a Where Clause - not updating table

I have a code that should take a table in a connected database, do some math to the geometry (makes lines straight) and then update the table data. It works up until updating the connected database - ...
1
vote
3answers
42 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
23 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
votes
0answers
20 views

ArcPy AttributeError: 'module' object has no attribute 'SeachCursor' [closed]

I'm running ArcGIS 10.6. Code and error below. Input file is SHP, and 'fieldA' is in SHP and populated. Not sure why it's throwing this error? Code: NextValues = [row[0] for row in arcpy.da....
1
vote
1answer
36 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
0answers
25 views

Insert 3d Polyline into (existing) Feature Class [closed]

I would like to insert a polyline object into an existing Feature Class (within a Python toolbox). Whenever I try to insert it with an Insert Cursor, I get the following Type Error: TypeError: cannot ...
0
votes
1answer
11 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
20 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
25 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
30 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
30 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 ...
11
votes
3answers
210 views

Is it necessary to delete a cursor used in a 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 ...
-2
votes
1answer
39 views

Stratified random point sampling in Python

I have a very basic knowledge in Python and arcpy. I want to create a stratified random sampling point on a continuous polygon. So far, I have dissolved the polygon (according to categories) and ...
0
votes
1answer
50 views

Using Update Cursor gives IndexError: list assignment index out of range?

I am trying to use an update cursor and receiving an error. I'm not very familiar with using cursors, so please bear with me. I am trying to write a 1 or 0 to a field, based on a condition. The error ...
0
votes
2answers
41 views

ArcPy if part of string not in field, then delete row

I am able to use UpdateCursor to find and delete rows if a field contains part of a string (code below works). Now I want to do the opposite--if part of this string is not in my field, I want to ...
2
votes
0answers
38 views

Python script to zoom to a city and export as PDF won't zoom to city [closed]

The script completes successfully but doesn't zoom to the given city. It does export to PDF with the correct name though. The map is the county wide extent and not zoomed to the given city. The print ...
1
vote
1answer
78 views

For loop within for loop with ArcPy cursor?

Below mentioned one is a part of my script.This is working when I assinged numbers for f.(Instead of "f" I have substitute 2.Then it is working).But i want to run this based on the no of rows of the ...
0
votes
2answers
24 views

Re-arranging date to mm/dd/yyyy and skipping empty cells in ArcMap using ArcPy cursor?

I'm trying to get my code to re-arrange existing dates in the cell to mm/dd/yyyy and skip empty cells. I thought by putting if None: continue would work but it's not. Any tips? Here is my code and ...
0
votes
1answer
44 views

Calculating field with ArcPy cursor?

I am trying to calculate field with the formula. I tried arcpy.calculate field management but still having difficulty. (10/10.4*(100*(math.exp(0.000871* !A!)-1+math.exp(0.000537* !B! )-1+math.exp(0....
0
votes
1answer
36 views

Writing to file geodatabase table using ArcPy cursor?

I wanted to copy a specific row of a table to another new table. So what I did was, copy the data of the row to a particular Array called c[]. Write them to a file Geodatabase table called Dead_T I ...
0
votes
1answer
47 views

Populate field with information from a different field based on matching record

I have a feature class created by merging multiple feature classes together, after the merge there are a lot records that have the same spatial attributes but different tabular attributes, except one ...
0
votes
2answers
33 views

Using cursor to delete rows with <Null> values in table using ArcPy?

I am trying to delete any record in my table that has a null value in a certain field (the Grid_Code field) and the code I have does not return any errors and seems to run fine, but doesn't actually ...
0
votes
1answer
50 views

Using UpdateCursor based on current selection of features

What I want to do is to manually select two features with the mouse (e.g. point or polygon), each in separate geodatabases to then copy the attributes values from one to the other (for only these two ...
0
votes
1answer
64 views

ArcMap 10.6 Select Layer by Location ERROR 000732: Selecting Features: Dataset does not exist or is not supported

I'm trying to calculate the accumulative street length in various jurisdictions in a county. To do this I'm using a search cursor in the city layer and then using the current feature to select streets ...
0
votes
1answer
19 views

If condition for a table in geodatabase in ArcPy?

I want to do what would be in a dataframe: if df['col'] = 1: do this.. but for a table in a geodatabase: if col = 1 in arcpy.ListTables("qt"): do this.. Purpose: For the rows that have in ...
0
votes
0answers
19 views

Using Update Cursor for multiple shapefiles

I want to use the Update Cursor function to add the data source to the attribute table for a list of layers that I have in an mxd. My workflow is as follows: 1- get a list of shp 2- add a field to ...
0
votes
1answer
19 views

Using arcpy.da.SearchCursor to obtain values from field that correlates with “year” field?

I am very new to coding. I am attempting to use SearchCursor to go through the attribute table of a feature class and return a list of unique years from the years field (which I have done). I am ...
2
votes
1answer
39 views

Writing ArcPy UpdateCursor based on row test?

I'm working on building a series of updates to street feature class based on fields inside the class. I was attempting to do this with update cursor to get better performance. When the ...
0
votes
1answer
30 views

ArcPy Cursor Where Clause to Delete Rows — why is if statement needed?

I am writing a function to delete rows based on a certain value. The first code block below doesn't work; the second code block does work. I don't understand why I have to add the "if" clause to get ...
-1
votes
1answer
45 views

More Pythonic way to loop through UpdateCursor?

I have several sets of fields to populate based on other fields. The code below works, but I am wondering if there is a more Pythonic way to march through the i,j pairs? (Actual fieldnames are not ...
2
votes
1answer
103 views

Condition if column from table is empty is not working?

I want to make a loop where if a column is empty in a row to do something else. The problem is that it can't determine the empty row. I tried as null, na , '',' ' and with double quotes and nothing. ...
1
vote
1answer
20 views

Populating set using for loop

I am attempting to create a single set of all the attributes read from a field on a feature class. This is my code so far: import arcpy workspace = arcpy.mapping.MapDocument("CURRENT") cursor = ...
1
vote
0answers
69 views

Arcpy InsertCursor inserting geometry into Shape field

I'm trying to write a script that reads geometry for each row in feature class, then create a new feature class and insert into it that geometry. It has to work with ArcGIS 10.0 so I have to use arcpy....
0
votes
1answer
89 views

Populating a Dictionary with an Update Cursor “Typeerror: 'Dict' Object Is Not Callable”

I'm getting the following error "Type Error: 'dict' object is not callable", with the code below: import arcpy def printDict(dictionary, printCount=False): for key in dictionary: arcpy....
0
votes
1answer
32 views

comparing parcel ids from two tables with arcpy.da.SearchCursor

My goal is to compare parcel IDs from two tables, one is a standalone shapefile and the other is a feature class inside a geodatabase (SQL Server). Both tables field name is "PARID" and the values are ...
-1
votes
1answer
66 views

Reading Text File to create Polyline with ArcPy?

This is carrying forward from the previously asked Creating Polyline shapefile from text file using ArcPy? With further insight from a colleague, I have the following code that I feel is a good ...
0
votes
1answer
32 views

Comparing each geometry of shapefile with all geometries of another shapefile using ArcPy?

I want to compare each polygon from one shapefile with all the polygons from another shapefile. When one polygon is geometrically identical to a polygon on the other shapefile, I want to copy the ...
0
votes
1answer
26 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
70 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
38 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
84 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
37 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
50 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
30 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
48 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/...
0
votes
0answers
29 views

Field Invalid in Script, Fine in Python Window

So I am trying to write a convenience script as part of a tool. All of the pieces work just fine separately, but when thrown together... not so much. The first sections take a user's input, does a ...
1
vote
1answer
38 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
36 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
60 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 ...