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

learn more… | top users | synonyms (2)

0
votes
1answer
59 views

Writing attributes and associated feature class name from file geodatabase to CSV?

I need to write a csv file that lists every record from an ID field across all feature classes in a gdb. The code I have written below does that fine, but I also need to write in the second column of ...
1
vote
2answers
59 views

Looping fields in an update cursor

I'm running an update cursor on an in_memory feature class to remove blank (but not null) values as part of a larger process. I wanted by update cursor to loop through my list of fields and if the ...
2
votes
2answers
56 views

Creating a list using an attribute query with arcpy.da.SearchCursor

I have a shapefile of a river network containing the following fields: toJunction, fromJunction, Int_DAM (which indicates free-flowing status) and Strahler. I'm trying to create a list of the rows ...
4
votes
3answers
363 views

Why [0] is needed in row[0] when using ArcPy (Data Access) cursors?

when running the following 2 sample codes, "[0]" is needed to be added after "row" in order to make code run well. I was confused. can anyone help explain? I know that it might be too easy for most of ...
1
vote
1answer
53 views

Arcpy get values in the 2nd field of every table in a geodatabase

I have a geodatabase in Oracle with around 50 tables. I want to get the values in the 2nd field of every table in my geodatabase. I will be using the values in the 2nd field as an input for a ...
1
vote
0answers
22 views

Cursor update row operator [closed]

This is a find and replace script I have been working on. I feel I am very close, as the script does everything but actually change the values, leading me to believe there is an operator issue. I have ...
2
votes
2answers
117 views

ArcPy Calculate Null Values to Zero in Multiple Fields

I have a table that has Null values and I would like to insert a portion in my script to calculate these Null values to 0 in only a few of my columns in my table. Here is my script so far: with ...
3
votes
1answer
42 views

Calculating summary statistics and access resulting value in table using ArcPy?

With arcpy, I want to calculate the mean value of a specific field in a shapefile and print the resulting value for the user. I use the Summary Statistics tool and it works, but the resulting value ...
1
vote
2answers
91 views

How to keep a parameter blank in a script tool?

I've developed a sort of find and replace script tool that functions. But I'm not able to figure out how to find empty cells in fields and replace them.For the "Find" parameter, I have tried ...
2
votes
1answer
27 views

Problems with insert cursor

I am counting the number of features in a geodabase. I am triying to insert the feature name and the count inside a dbf table which has only two fields: "FEAT" (Text field which containts the feature ...
2
votes
1answer
74 views

Developing find and replace script tool?

I'm being tasked for developing a script tool that can find ultimately needs to be able to find any string and replace it with another string in an attribute table. Below is what I have so far, and it ...
1
vote
1answer
59 views

Insert (or Update) Cursor setting value to None not honored when field has a default value

To set a field to null, the InsertCursor or UpdateCursor is setting the value to None. Here is a sample for the UpdateCursor: with arcpy.da.UpdateCursor(test_fc, ['SERVICEINDICATOR'], """"OBJECTID" ...
1
vote
1answer
56 views

How to update new column in attribute table with same values but different field type?

I am struggling a bit with debugging my code, over something that seems very simple. I am using an update cursor to copy and convert existing string data into a new float column of my shapefile's ...
0
votes
1answer
43 views

how to skip creating an empty feature class using featureclass to featureclass in arcpy

I have a script that finds points outside of selected areas and creates a feature class in a file geodatabase. However, sometimes there are no points outside of the selected area. Currently, the ...
2
votes
1answer
44 views

Arcpy “print” works only the first time [duplicate]

I am running this extremely simple code using the ArcGIS python environment: import arcpy test = r"C:\....\New_Shapefile.shp" #test contains several fields, including one called "Number". ...
1
vote
1answer
30 views

Replace Statistics_analysis with SearchCursor?

I'm using ArcGIS 10.3, 64bit with an advanced license. I have the following code, that runs just fine. It goes through a table that contains a large number of entries with zip-codes and population ...
0
votes
0answers
29 views

Trying to delete specific features within feature class

I am working with arcmap 10.2. I have a database that has a few feature classes in it. Within these feature classes, they have a field labeled as Height. Height is a string field that houses numbers ...
4
votes
1answer
48 views

Update row with next row's value

I am trying to extract the endpoint of a line with very fine scale and overlapping GPS data. I would normally just use the locn_id+1 but that doesn't work because the data were originally rarified. ...
4
votes
1answer
93 views

How to delete rows in attribute table of a shape file based on specific condition?

I want to delete ceratin rows in a shape file if field ID is equal to certain number (say 2). Below is what I am trying, import arcpy shape="C:\Users\Data\Loc.shp" rows = ...
1
vote
1answer
59 views

arcpy SearchCursor always empty at each loop when inserting new rows with InsertCursor

I am inserting new rows into a POINT FeatureClass within a geodatabase. The way I do it is by creating an InsertCursor over an empty FeatureClass and inserting new rows while loopinf through the ...
0
votes
1answer
58 views

Arcpy: Geometry object - distanceTo method in a for loop

I'm new to Python so sorry for this maybe trivial question. I have 4 lines and 4 points, which belong together. I want to get the closest distance from point 4 to line 4, point 3 to line 3, ... . I ...
2
votes
2answers
62 views

Update value in one table (feature class) by coping it from another table. The match between table is done on values from another field

I have two tables (actually both are feature classes in filegeodatabase). They pretty much identical except. one is in lat/lon. second one is projected. both have field line_length and objectid. ...
-1
votes
1answer
44 views

Exporting maps to pdf

I need to create a PDF book of all counties in a counties shapefile. I now have to use a cursor and a for loop to get individual counties, but I'm not sure how to go from there. I'm not allowed to ...
1
vote
2answers
71 views

script to grab value from field and input into SearchCursor then select results for further analysis

The data: PL_Fac -point file - facilities used in service area analysis - contains PNTID in Add_PNTID field PD - polygon - catchment areas assigned to a facility (there can be many polygons ...
1
vote
1answer
52 views

Extract Polygons out of a raster

I want to extract every row from a .shp from a raster (Extract by Mask). With the following code i get 4 output raster, wich concludes every row. import arcpy arcpy.CheckOutExtension('spatial') ...
3
votes
3answers
75 views

How to generate a list of unique years from date field?

I have data that was collected over many years and I'd like to be able to run a python script tool in ArcToolbox (ArcGIS 10.1) to get a list of unique years from the date field. I found an example of ...
3
votes
1answer
53 views

How to slice a list based on row values? [closed]

I'm working with python 2.7 (quite a beginner). I have a list, and I have a feature class with : A = a field that contains values that I would like to use as the start of the slicing B= a field that ...
3
votes
1answer
58 views

ArcPy SearchCursor row format

I set up a script to print some statistics about line segments. The "logfile" is basically the same as "print", but to a textfile instead of on screen only. LogFile("Feature {0} has a length of ...
2
votes
1answer
96 views

arcpy.UpdateCursor updates every row

I would like to update a field with new values. With the code below it assigns the value '2' to all the rows and not just if the field == 2. But by 'print i' and 'print "it is 2"' everything looks ...
5
votes
1answer
137 views

UpdateCursor gives Too few parameters Expected 1?

Can anyone tell me why my script isnt working? I cant figure out where I went wrong. I am working with an access personal geodatabase. Adding a field, then updating that field with yes if the field ...
1
vote
2answers
88 views

Updating firstPoint and lastPoint using ArcPy cursor?

I want to update a Line feature's start and end. I got Point of first and last. BUt, I can't update them. What is wrong ? (I'm using ArcGIS 10.2) rows = arcpy.UpdateCursor(srcFile) feat = ...
4
votes
2answers
112 views

Python script that creates polygon feature class with given coordinates

Write a script that creates a new polygon feature class containing a single ( square ) polygon with the following coordinates: ( 0, 0 ), ( 0, 1,000 ), ( 1,000, 0 ), and ( 1,000, 1,000 ). ...
5
votes
1answer
86 views

Writing points to a file

Trying to write the city name and point coords to a file. The following works with a polygon shapefile but not the point shapefile. I know I'm missing something basic. import arcpy # Set up the ...
3
votes
1answer
117 views

Append List not working

Trying to create a list of well counts. In the code below, wellCntList only contains the current county count and not a list of ALL the counts. Sure I'm missing something simple. for cname in ...
3
votes
1answer
55 views

Add shp attribute data to column with python script

If feature column (feature is the name of the column) in table is ferry crossing in the attribute data then I need to add Yes to the Ferry column that I have already added to the table. If the ...
2
votes
2answers
84 views

Column does not exist - python

My goal is to count the number of wells in each county. I've verified the columns are correct as listed in the attribute table. Do I have a typing or formatting error? I wanted to pull county names ...
0
votes
1answer
91 views

Improving processing time of ArcPy script?

Background: I work for an electrical utility, and we have a point feature class called "meters" that contains approximately 35,000 records. These records represent the actual power meter, and contain ...
0
votes
1answer
55 views

replace ü/ ö/ ä / spaces and brackets in Attribute Table [duplicate]

I've got a Polygon Feature Class of communities in switzerland. Unfortunately, the names in the attribute Field "NAME" include spaces, brackets and ä/ ö/ ü characters. For further processing, i need ...
0
votes
0answers
76 views

arcpy UpdateCursor throws exception on geoprocessing service?

I wrote Python code that changes the state of a feature by ID. I am not using a Python Toolbox (.pyt). I wrote a python script and added it into a standard toolbox (.tbx). Using ArcGIS Desktop ...
0
votes
3answers
89 views

Assign Mask From Layer in SearchCursor Loop In ArcPy: Error Accessing Environment

I'm trying to run a loop based on a SearchCursor that selects layers from an input polygon and polyline. I want to select a feature from the polygon to use as a mask for running Euclidean Allocation ...
0
votes
1answer
129 views

Using Update Cursor to update all fields in a feature class based upon another feature class

I have perused GIS stack exchange to find an answer, but haven't quite found what I am looking for. Question: I am trying to update all the fields in a feature class based upon field values from ...
1
vote
1answer
40 views

Updating null values in appended feature class

I am creating a customized script tool that first clips out a line feature from one feature class, dissolves the fields of the clipped feature class so that just one feature is in it, appends the ...
3
votes
2answers
57 views

Fetching single value without Cursor in ArcObjects?

I used the below function to get the single value using ArcObjects. private string getApproverAlias(string checklistId, bool isDeleted) { string approverAlias = ""; var masterTable = ...
1
vote
2answers
59 views

IndentationError: expected an indented block

I am getting the IndentationError in arcpy. I understand this is covered elsewhere but none of the tips appear to be working, I cannot figure out the error. Here is my code; def getCoords(self): ...
3
votes
1answer
163 views

Using Update Cursor, populate field

I am trying to write a script where you preemptively select features and then go to the tool which calls for the feature layer and it populates fields based on certain criteria which I will design of ...
1
vote
1answer
57 views

arcpy SearchCursor is creating a comma within a tuple

I am creating a list of tuples of coordinates of a feature class. Feature class is created as such: inFC = arcpy.GetParameterAsText(0) The inFC is a point feature class. I then have the following ...
1
vote
1answer
200 views

Arcpy SearchCursor (arcpy.da) - Assign cursor value to variable [closed]

I am trying to use arcpy.da.SearchCursor to get the values of two field for each reach record in the DISTRICT feature class. I need to assign these values from the table to a two variables varRegion ...
1
vote
1answer
104 views

Trying to increment a field value for only the repeated records in a feature class using Python

NOTE: If you look at the excel tables just above the comment section it will give a clearer picture of what I want to achieve in my code. So the code below works in doing what I want it to do thus ...
3
votes
1answer
302 views

Selecting rows in a layer using arcpy.SearchCursor

I'm working on a project to identify points that fall along lengths of road. The roads are stored a single featureclass within a file geodatabase, as are the points. I'm using ArcGIS 10.3. I'm trying ...
0
votes
1answer
34 views

UpdateCursor based on results from SearchCursor

i'm kinda stuck with an UpdateCursor. This is what I'm trying to do: each cell of a grid stores multiple answers that were given in a survey. For each cell I must choose only ONE answer, the one that ...