Questions tagged [python-parser]

For questions about ArcGIS Python Parser for labelling expressions and field calculations

Filter by
Sorted by
Tagged with
1
vote
1answer
97 views

Calculate number of alpha characters in field to a new integer field - ArcGIS [closed]

In a feature class field (screenshot below), I'd like to know how I can get a count of the alpha characters in each record and calculate it to a new field. I have a "FieldCount" field that calculates ...
1
vote
1answer
357 views

Run field calculator script in Python window

I have a script that runs perfectly in the "Field Calculator." The codeblock looks like this: def timeday(time, am, diur, pm, noc): if(time >=am and time < diur): return "crep_am" ...
1
vote
2answers
79 views

Adding new text field using if/then python statement?

I was hoping someone could help me with an issue I've been having while trying to aggregate data into a new column in an attribute table in arcgis. This is part of a model built using model builder. I ...
1
vote
1answer
271 views

Field Calculator Odd IF Statement?

I am working on a street addressing project. I want to add a number to every odd number. Example if [field] is odd [field]+=1. How can I do this in ArcMap using the field calculator. I used to work ...
1
vote
2answers
380 views

Python in the Attribute Table

I am trying to add new text ID's to a field using a basic counter function within the field calculator. I have two questions here 1. does the field calculator always have to use a function or can it ...
1
vote
1answer
60 views

Arcmap: Unable to detect empty value in row using Field Calculator

I am using the following pre-logic Python code to try to catch Null, empty, or "0" string values in the "street" column and then return a "V" value if it is one of those. While the code runs and ...
1
vote
2answers
740 views

Sum value ArcGIS attribute (field calculator)

I have in my columns attribute the following table ( follows the image): "rank" (which is related to the order of my data); "SL" (which is a linear measure of my object); "testada" (the formula): ...
1
vote
2answers
171 views

Label expression help with loop field and multiple fields

I have 13 fields I need to Label all in one Label. But I dont want to label values with zero. Need to have Label before each field example (Field is (C_B) and need to read C&B, 2). Here is what ...
1
vote
2answers
114 views

Calculate text field using python script and keeping preceding zeroes

I'm trying to calculate records in a text field to "01", keeping the preceding zero in tact using python script in ArcGis. I can do this easily using the field calculator in ArcMap or the calculate ...
1
vote
1answer
113 views

Python/VB Script Field Calculator

I'm new to Python/VB Script and am needing some help. I have tried several different If/Then statements but can't seem to get it straight. I am hoping for some help. I have 3 fields. ZONING, ...
1
vote
1answer
77 views

Getting “real time” occurence count of values in attribute table for displaying purposes

I'm working with ArcMap 10.2 on a layer of points that I have to move. I'm using the editor to move them. What I also need is to display these points based on how many are sharing the same coordinates ...
1
vote
2answers
120 views

Comparing two fields and printing result as 1 (if number matches) or 0 (if not) using Python Parser of ArcGIS Field Calculator?

I have two fields named as "sample no" and "data_all" trying to find out whether "sample no" exist on "data_all" or NOT. Using field calculator python 9.3. if exist print 1 if not print 0 in check_in ...
1
vote
1answer
186 views

ArcGIS Issue with Python wildcard in Label Expression?

Here is my current expression: def FindLabel ( [FULL_NAME] ): fn = [FULL_NAME] if "COUNTY ROAD" in fn: return "CR " + fn[11:] elif "% COUNTY ROAD" in fn: return fn[:1] + "CR" + fn[13:] else: ...
1
vote
1answer
540 views

Python script for if/elif condition in field calculator [duplicate]

I need some help in calculating the last column (OD_pairs.Ai_) based on the condition; if travel_cost has a value below 10, OD-pairs.Ai_ takes the value of the first column(Aij_OjFCij..) if ...
1
vote
1answer
92 views

Using python to do a interpolation on field calculator [duplicate]

I need to increment a row in attribute table: def func (w,v,pot): return pot + ((pot+1 - pot)/(v+1 - v))*(w-v) The "+1" is not the addition of number one to the variable, is the intention to ...
1
vote
1answer
116 views

calculate specific rows and populate their result in another field

I'm working on ArcGIS 10 desktop version. I have a file with one entity entered multiple times (rows) and each time that has been given a new value against it. I want to sum the values against this ...
1
vote
1answer
194 views

Using Field Calculator with Python Parser and if/elif statements in ArcGIS for Desktop? [duplicate]

I have tried all of below snippets to use Python Parser in Field Calculator and update the values of a field called type based on a filed called MamerMN but in all of them I am getting Syntax error in ...
1
vote
3answers
331 views

Autopopulating text field with string and number combination

I have an attribute table with a text field which indicates a unique identifier for each row. The identifier includes a combination of text and numbers, sequentially increasing, as follows: PHOTO_0001....
1
vote
2answers
939 views

Set parameter of field from number to string with Python

Since I realised Python is a very useful tool in ArcMap I don't want to do any workarounds any more. I have a field with is numeric, but I want to perform this calculation in the field calculator on ...
1
vote
1answer
141 views

Calculating average of 3 fields where nulls are present

I have created a new field to calculate the average of 3 other fields in a table where nulls are present. Using python as the parser(with no code block) I used this: (!Slope_PCT! or 0 + !Flood_PCT! ...
1
vote
1answer
4k views

Conditional calculation of Text field value based on another text field value using ArcGIS Desktop? [duplicate]

In ArcGIS Desktop 10.1 I created a new field to explain some zoning codes in an attribute Table. I basically want the new field "Zone" to have a string value based on the field "Zoning". For example ...
1
vote
3answers
5k views

Replacing NULL values in geodatabase table?

How do you update NULL values within a geodatabase table using the ArcGIS Field Calculator (service pack 4) without changing other values to NULL? I've tried the suggestions on this previous question:...
1
vote
2answers
23 views

Writing if/then Statements for Python Parser of ArcGIS Field Calculator

For some reason I cannot get this code to work in the Field Calculator of ArcGIS Desktop 10.6.1. I'm trying to use the Python parser to populate the field "SHAP_CLAS" with multiple conditional ...
1
vote
1answer
37 views

Calculating field from three conditional statements

I am working on a road dataset and would like to calculate a field(speed) using three conditional statements from two fields: formOfWay: with value, Dual carriageway etc. routeHierarchy: with values ...
1
vote
2answers
52 views

Use a python expression in Field Calculator to sum each row across several columns

this seems like it should be easy but I am new to python and am having trouble... I have four columns. I would like perform a field calculation that sums the values by row for three of the columns and ...
1
vote
1answer
159 views

Simple Field Calculation With No Results in ArcGIS Pro?

I have a grid in ArcGIS Pro that I've named the X and Y axis (in separate columns) and am now trying to do a field calculation on the total grid name (I've tried using both single and double quotes. I'...
1
vote
1answer
236 views

Using ArcGIS Field calculator with global variable?

I have an issue with creating a field calculator expression in python that utilizes global variable. How my table looks like: This is a fragment of road network shapefile. Each road has a code (...
1
vote
1answer
60 views

Using ModelBuilder with Field Calculator gives SyntaxError?

I am brand new to coding, have no background at all. Basically I have about 200 tables with the same info listed under slightly different attribute table headings and I am trying to rename them to ...
1
vote
1answer
54 views

Using Python codeblocks in ArcGIS to evaluate if all values in many columns is 0

I'm working on zoning data and I've been evaluating if the percentage for various zoning is more than 90% of the area, so I can define it as that zone in a new field, like so: def ifBlock(RS, RM): if ...
1
vote
1answer
56 views

Replace attribute value with non NULL values from a joined attribute column [duplicate]

I have a Geodatabase with a column for pipe diameter. I have a secondary data set with field verified data and a column for pipe diameter. I would like to replace the pipe diameter in the Geodatabase ...
1
vote
1answer
29 views

Sort User Defined Features Classes Into Premade Feature Dataset Using ModelBuilder?

I have a large Model where the user selects the text file, it creates the xy file, then decimates the file, thus creating a feature class. I would like this decimated feature class to get sorted ...
1
vote
1answer
38 views

Arcgis Label Expression based Value

I am trying to make election map so I can draw chart and label with same chart color. So I have six election zone and running candidates may be up-to six or less. So if some election zone might have ...
1
vote
1answer
242 views

Syntax Error Label Expression Debug

I'm attempting to debug a code for a conditional label expression. The code is based on one i have previously used and did not have any issues. The python code is as follows. def FindLabel ( [TF], [...
1
vote
1answer
93 views

Using an IF statement in Field Calculator

I'm trying to use an if statement in the field calculator: This is what the code looks like in Python: a= 2 FacilityID= !FACILITYID! if a%2==0: MH_ID_Calc=FacilityID[0:6] else: MH_ID_Calc=...
1
vote
1answer
118 views

Field Calculator: extract single cell based on it's OBJECTID?

Is it possible to copy a single value inside a field based on it's OBJECTID from another field? Some sort of if-then-else logic? For example I would like to copy the value in the Area field ...
1
vote
1answer
949 views

Error Label with Python: encoding declaration in Unicode string (<string>, line 0)

I get this error using Python while I'm trying to label a shapefile. The strange thing is that for other shapefiles the code works. There is a table (relates.dbf) that has the data to be used for ...
1
vote
2answers
247 views

Checking for values in one column and do something in another using ArcGIS Field Calculator?

I have two columns: "Street1" and "Verified". I need to check all rows in Street1 to see if they are of string "0" or null. I've attempted to come up with something in Field Calculator but it is ...
1
vote
1answer
38 views

Addressing fields in ArcGIS field calculator dynamically?

I am (re-)learning ArcGIS for a new job after couple of years on PostGIS (and QGIS/pyqgis) and can't figure out how I can address a Field within the pre-logic-block of the field calculator. Pre-Logic-...
1
vote
1answer
196 views

String value as a number in modelbuilder

I have got a drop-down list of values in my model. There are word combinations that do not exist in my table. One of the tools in my model should select string data of a field by number of characters ...
1
vote
1answer
164 views

Populating ArcMap column with inputs from other colum, shortening original text? [closed]

I need to keep the first part of all inputs and get rid of the last part, so that i can later make a join based on the new attribute. Edit: found solution by using simple python script !MY_FIELD![:-...
1
vote
1answer
408 views

CalculateField by dividing with a variable that holds a number

I'm trying to calculate a field (using idle python to write my scipt and working with ArcMap 10.3) by dividing two fields then dividing by a variable that holds a number, which the number was ...
1
vote
1answer
82 views

Rearranging display of Date Field in ArcGIS Desktop?

Can you rearrange the text in date field type in ArcGIS? Eg. Map_Date - 05/30/2014 (I want to reformat this to 2014-05-30) I've been trying to use the field calculator on all my records, but cannot ...
1
vote
1answer
689 views

Using python script in ArcGIS field calculator?

I am using ArcGIS 10.3 version in desktop. I wanted to assign landuse names (Landuse_04 column) based on the codes those are in my attribute table as the column ID_MAP. once I am done with editing the ...
1
vote
1answer
48 views

Parsing Attribute Table

I have thousands of records to go through and I need to pull out a specific date. Heres the set up of the fields one field is full of Null values and the second field is an ID field that looks like ...
1
vote
2answers
300 views

Parse multiple field in field calculator using python

I'm trying to fill a blank field depending on the contents of three other fields using python in the field calculator. Sample code is something like: def getClass(Text1,Text2,Text3): if Text1 is ...
1
vote
1answer
29 views

XY_LINK field using Point_X & Point_Y Fields

In the below image, I am trying calculate my XY_LINK field to return the values from Point_X and Point_Y field. Example of final result: {2474785.499662}{376075.063004} My code is as follows: ...
1
vote
1answer
1k views

Extract characters from an existing string field to create a new field

I have a string field named CHESS2016_N94S_FL1_C__20160407230029.562GMT_COLOR-8-BIT.JPG and I would like to select characters 16-18 to populate a new field. I've been trying to use the field ...
1
vote
1answer
69 views

Stacked label with parentheses and exclusion

I'm doing some labeling and have my labels stacked using python by using the following: [field1] + 'n\' + [field2]. But I'd like to keep the label stacked and add parentheses to [field2] as well as ">=...
1
vote
1answer
122 views

Calculate field tool vs Field Calculator

I have successfully populated a field in Arc using the Field Calculator, however I would like to re-create this in python as part of a tool I am making. I was going to do this buy using 'Calculate ...
1
vote
1answer
78 views

failed to Writing conditional (if/then) statements into Field Calculator of ArcGIS for Desktop using Python parser?

I wrote this following several examples but it is still wrong. I need to populate a new field based on 5 ranges of values. def marks(Wards for try.JHRatio ): if (Wards for try.JHRatio <= 50)...