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
835 views

Null output from field calculator code block

I have a simple calculation to compare two columns and populate a new column with the lower value but I am getting null output...any ideas? expression re_score(!Signal_Strength!,!Signal_Strength_1!,...
1
vote
1answer
375 views

How to tranform a column field into a list using Field Calculator

I'm trying to make a simple field calculation with ArcGIS 9.3: New field = Old field - Old field(first value) which in Calculate Field with python code should be Expression: !Old field! - first ...
1
vote
1answer
35 views

Re-ordering text strings within field using Python Parser of Field Calculator

At ArcGIS 10.8.1, I have a shapefile attribute table containing a text field with names ordered last, first, middle, as in this example: Smith Sally J Doe John Jones William Randolph ... I need to ...
1
vote
1answer
36 views

Writing Field Calculator codeblock using Python parser of ArcGIS Pro

The following code isn't working as expected and I'm not sure why: UpOrDown = reclass(!UpOrDown!) def reclass (Z,GP): if (GP == "DT" and Z == "CG"): UpOrDown = 1 if (GP == "DT" and Z ==...
1
vote
2answers
1k views

Adding Hyphen between text in Python Parser of ArcGIS Field Calculator

I have list of numbers like this (S20170146) and I want to turn them to this format(S2017-01-46).Basically, I need to add "-" between the numbers. I am using Arcmap I know how to use feild calculator....
1
vote
1answer
36 views

Auto incrementing every second row in ArcGIS Desktop?

How do I auto increment every second row (field type is short and I work with 150 fields) in ArcGIS Desktop 10.3.1? I saw this code in https://support.esri.com/en/technical-article/000011137 rec=0 ...
1
vote
1answer
177 views

Reclassifying field using Python wildcard string search?

I have a point layer with 900K Tree Point records. In that layer I have field (d_Species) that contains the tree species of each record. I've created a field (SpecieValu) to assign a value (0-3) for ...
1
vote
1answer
56 views

Using Python Lists in Calculate Field Code Block? [closed]

I'm looking for some help in explaining what exactly is occurring with the following code: MaterialLife = "LifeMaterial(!"+Material+"!)" codeblock2 = """def LifeMaterial(mat): material = {"ABS":...
1
vote
1answer
52 views

How to turn a string field with 2 numbers in two numerical fields in the atribute table?

I have a feature class with a big number of features. In the attribute table I have a string field made from two numbers separated by an underline (e.g.: 0_1, 98_237, 31_31...). I want to create two ...
1
vote
1answer
42 views

Python Labelling in ArcGIS - Two Languages one string

I am trying to format a label in two languages in a way they appear on one line and not stacked in ArcGIS any ideas? Maplex Stacked label feature is not ticked so this does not help. This is how they ...
1
vote
1answer
41 views

Failed to Generate Incremental ID with Following Python Code in the Code Block. What's the mistake in my code?

I am trying to add a field with incremental ID for a shapefile with certain feature classes. I know this can be done by using Sort tool and then use the Add Incremental ID field tool. But since I'm ...
1
vote
1answer
32 views

Classifying text field 'B' using integer in field 'A'?

I wrote an if elif statement that will loop through records (field A) and populate a new field (field B) based on A's contents. Field A name is 'CLASS'. Field B is 'class_desc'. reclass(!class_desc!...
1
vote
1answer
492 views

ArcGIS Field Calculator Not Working With Date Field

I am trying to calculate a field based on the date values in another field. Here is my code from the pre-logic script code box: def getHalf(dfield): if dfield >= date '2017-08-27 00:00:00' AND ...
1
vote
1answer
149 views

Creating If Then statement in Field Calculator between 2 values? [closed]

I have a FC with a column for NEAR_ANGLE from the output of the NEAR tool. The angle is displayed in degrees (i.e. -154.67687) which is fine. I am trying to create a column, HEADING, that reads this ...
1
vote
1answer
63 views

Populating comment field using Python Parser of ArcGIS Field Calculator?

I am new to using Python and seek help building a code for an ArcGIS project. I took one introductory C programming course in school, but other than that I am green. My objective is to have the ...
1
vote
1answer
209 views

Multiple Conditionals String with ArcGIS Field Calculator?

I am trying to use Field Calculator to use a multiple conditional based on a string in another field of the same attribute table. I have written the code below, but without success. Pre-Logic Script ...
1
vote
1answer
112 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
445 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
87 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
333 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
485 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
66 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
1answer
2k views

How to concatenate string and noneType object

My issue is: I can't concatenate string and noneType object. Some attribute values are empty. It follows that label isn't displayed. What is the solution? def FindLabel ( [CONTENU], [...
1
vote
2answers
1k 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
174 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
123 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
114 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
79 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
125 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
204 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
559 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
94 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
117 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
203 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
353 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
949 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
153 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
1answer
29 views

Exclude certain values in string field when labelling in ArcGIS Pro [closed]

I am trying to label a field on a map but exclude certain text strings from appearing. Specifically, I am working with pipes and their labels. The string values include the pipe size and material so ...
1
vote
1answer
19 views

Using Python to label points with format dependent on date of measurement in ArcMap

I have a database of wells and water level measurements which I would like to label in a stacked manner with the ID on top and the measurement below it. If the measurement is from 2020, it should ...
1
vote
2answers
51 views

Combining two simple scripts into single script in Python Parser of Field Calculator

I have two separate scripts used in Field Calculator for an "ID" attribute field. Script 1 is to create sequential numbers for the field. Script 2 is to add leading zeros to the sequential numbers. ...
1
vote
1answer
35 views

Conditional statement using Long and Text fields with Python Parser of Calculate Field in ArcGIS Pro

I have 3 fields: "ISL_Numero" - Long (values are '1', '2', '3', '4' etc.) "Subtipo_IS" - Text (values are 'A', 'B', 'C' etc.) "Ambiente_C" - Text (values I want to ...
1
vote
2answers
57 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
42 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
82 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
390 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
346 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
77 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
6 7
8
9 10
12