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
votes
1answer
20 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
47 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
17 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
76 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
45 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
38 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
46 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
55 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
68 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 ...
2
votes
4answers
167 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
91 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
29 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
78 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
46 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
141 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
43 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
81 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
186 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
37 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
81 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
16 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
33 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
585 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
109 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
37 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
654 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 ...
-2
votes
1answer
146 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
312 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
58 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
58 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
101 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
32 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
86 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
38 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
67 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
100 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
373 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
95 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 ...
1
vote
1answer
21 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
1answer
36 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
56 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
74 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
48 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
118 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
24 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
185 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
442 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
45 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
265 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 ...