Questions tagged [python-parser]

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

Filter by
Sorted by
Tagged with
2
votes
4answers
576 views

Setting up Concatenation using Python expression in field calculator?

I am having trouble creating a Python expression in Field Calculator in ArcMap 10.3.1. I’m attempting to concatenate two field values (double and short integer) to a third (double) field, (CON_IN). I ...
2
votes
2answers
157 views

Converting none to zero (0) in geodatabase table using ArcPy?

I have an attribute table looks like this How do I convert Nulls into 0? I've tried to set this table non nullable type but got this: while the official doc says this: At least one of them is ...
2
votes
2answers
85 views

ArcMap python field calculator function

I have a field that has three entries as strings: "278957", "278961", and "12345678". When I use if/elif/else I can correctly replace the first two conditions in my code below but the problem is that ...
2
votes
2answers
348 views

Python script for filling <Null> values with previous value in one field

I have a table (inside a File Geodatabase) that looks like this: I need the values of Owner attribute to be automatically filled with the previous non-Null value. As Such: Is there a Python script, ...
2
votes
4answers
610 views

Concatenating address fields with possible blank or null values in fields using Python parser?

The following Python code is what I have already tried in field calculator of ArcMap 10.5.1: Pre-Logic Script Code: def ConcatAddr(!JOIN_KEY!) val = "" if !Address! <> val ...
2
votes
1answer
573 views

How to remove first two and last two characters from each label in ArcMap [closed]

My too long labels take up too much space in regard to the small counties polygons. I want to remove first two and the last two characters from each single label. Currently the labels on the map look ...
2
votes
2answers
179 views

Getting only time from Python parser of ArcGIS Field Calculator?

Using ArcGIS 10.4, how I can modify the Date() functions on VB or Python scripts of field Calculator Now ( ) datetime.datetime.now( ) to get only time like 12:32
2
votes
2answers
364 views

Use field calculator to return the word after “unit”?

Working on ArcMap Desktop 10.5; the file in question lives in a file gdb. I have a polygon layer with a field of full property addresses (string) from which I need to extract ONLY the unit number, to ...
2
votes
2answers
218 views

ArcMap Field Calculator Python string concatenation malfunction

I am trying to concatenate three fields into one using Python with the rjust padding function. My function in the code box is the following: def AutoSchluessel(gmk, zae, nen): return "{}0{}{}"...
2
votes
1answer
207 views

Create Classes based on Field Values using Python in the Field Calculator

I'm using ArcGIS 10.3 and I want to create classes (1-4) in a field called "Util_Class" based on the values of a field called "OverallUtil". I think I have syntax error and have been entering this ...
2
votes
2answers
104 views

Using Python in the Field Calculator to select more than one data point

I assume this is a basic Python coding question, but I have scoured the internet and spent several hours trying on my own. I have about 2000 cells in my FID_1_1 column that I need to select and code ...
2
votes
2answers
1k views

Field Calculate to remove certain values in field

I have a field named "ZIP" which has the zip code information for numerous records. Some of them have 9 numbers, but I only want them to have the first 5. What should my Pre-Logic Script look like to ...
2
votes
1answer
2k views

Converting text to proper case using ArcGIS field calculator?

I am working on a set of data that has over 40,000 records on ArcGIS and I want to use a Proper Case for several fields/columns on the table. Is there a Python Script that can help me automate this ...
2
votes
1answer
1k views

Python Syntax Error 000989 when running Python Snippet of successful geoprocess?

I am having an issue with a simple python snippet. Here's the background: I wanted to include an additional step in a nightly update script that replaces characters in a field that simply do not play ...
2
votes
3answers
7k views

Python script for identifying duplicate records (follow up)

I am trying to calculate a field that marks duplicates and sequentially numbers them. I am using the code below that I found here: Generating sequential numbering for duplicate values in a field ...
2
votes
1answer
52 views

Using If statements to conditionally populate a field in Field Calculator

I'm trying to use the field calculator to poplulate a string field in a table based on info in another string field. This is what I have: def Reclass(Correction_Comments): if (MSAGSTREETNAME) = '...
2
votes
2answers
163 views

Using Python in field calculator to extract highest value from 3 columns [closed]

I have three columns, one for percentage White, percentage Hispanic, and percentage African American per census tract. I'm trying to use Python to extract the population subtype with the highest ...
2
votes
1answer
256 views

split attribute using ArcGIS Field Calculator

I have a long string in one attribute. I want to be able to extract a small portion of it into a new attribute. This is an example of the attribute: "< html xmlns:fo="http://www.w3.org/1999/XSL/...
2
votes
2answers
144 views

Make ArcMap label using the first letter from each word in an attribute [closed]

How do I create labels using the first letter of each word from a specific attribute, preferably using Python as the parser? For example, the attribute name is Common_Name and the values are eastern ...
2
votes
1answer
533 views

Use Python in ArcGIS Field Calculator to return value based on numeric value in any of three other fields

I am trying to calculate a new field in ArcGIS 10.5 Desktop using the field calculator, based on the value in any or all of three other fields in the same table. I have not used Python for a while, ...
2
votes
1answer
365 views

Calculating mean value of 280 fields with Field Calculator from attribute table of shapefile?

I have to average 280 fields in 1 field. Each field has 300 rows. That is my problem. I think I need a python script. I don't want to create a raster for each field and then use the raster ...
2
votes
2answers
221 views

ArcMap label with python if elif

I would like to translate a vbsript expression into a python expression. But it doesn't work! Here is the code in vbscript: Function FindLabel ( [CONTENU], [NOM_OBJET_USUEL], [ALTITUDE_FIL_EAU_M] ) ...
2
votes
1answer
1k views

Using Null values in Field Calculator

I have a python script in the field calculator that reads dates and populates a status field. When there is an empty value in the "actual" field, that is the status of the project. Here is the code ...
2
votes
1answer
113 views

Dealing with zeros while iterating a model for percent change

I'm using ArcGIS to examine some aquatic vegetation changes over time and I have created a model that adds two fields: Area_percentLoss and Biomass_percentLoss. My model is iterating over feature ...
2
votes
2answers
106 views

ArcGIS10.2 Field calculator problem with strings

I am trying to do a simple concatenation using the ArcGIS 10.2 field calculator with Python code. I have a field of census tracts numbers (tract). I want to concatenate this with the numeric codes for ...
2
votes
1answer
76 views

Help with else/if else in arcMap? [closed]

I'm attempting to create quick code that simply assigns a gps coordinate to a certain station on the map. Here's my current code Pre-logic script code: def update_nones(lat,bay_statio): if bay_statio=...
2
votes
4answers
620 views

Unable to replace Null values using Python parser of ArcGIS 10.0 Field Calculator?

I'm using the following python code to replace Null values by 0, using field calculator: def nulls(p1): if p1 is None: return 0 else: return p1 But nothing happens, Null values stay. I'm ...
2
votes
1answer
508 views

Debugging Indentation error on Python Parser of ArcGIS Field Calculator?

Would anyone please help me find out why I get an indentation error in line 3 def calc(f1,f2,f3): remove_list = ['01ST', '02ND', '03RD', '04TH', '05TH', '06TH', '07TH', '08TH', '09TH'] if f2 in ...
2
votes
1answer
4k views

Converting field to string with leading zeroes using Python Parser of ArcGIS Field Calculator?

I would like to create an expression using the field calculator in ArcMap to be able to convert an Int field to a string and add leading zeroes. I am able to do it in a python window with an example ...
2
votes
1answer
2k views

Using Python if/then/else to return value from either of two fields based on value of third using ArcGIS Field Calculator?

I'm trying to avoid manually inputting Begin and End engineering station values already inputted into a seperate field. I'm dealing with(4) fields: Begin_Sta End_Sta Beg_End and Station. The ...
2
votes
1answer
140 views

Using Field Calculator to split names but want to start count from right?

Just learning python on my own as I'm working. I have a column of street names where some are two words or three words, so counting spaces from the left to the right is outputting incorrectly for me. ...
2
votes
2answers
120 views

Identify closed polylines in ArcGIS using Python

Running ArcGIS 10.2 here and a complete beginner with Python. I'm trying to figure out a workflow to test for closed polylines using the field calculator. Essentially what I'd like to do is to ...
2
votes
2answers
53 views

Trouble with if loop in Field Calculator

I'm trying to calculate a field using Python with field calculator but am running into a syntax error. I'm hoping someone can point out what the error is, and I can't seem to figure it out. Below is ...
2
votes
1answer
127 views

Syntax for evaluating strings with wildcards

I'm trying to do a Field Calculation in ArcGIS 10.3 (Python 2.7) that uses the Codeblock (Pre-Logic Script Code) to evaluate the attributes in a different field to inform the calculation). Here's an ...
2
votes
2answers
147 views

Labeling specific features in ArcGIS for Desktop?

In ArcGIS 10.3 for Desktop, I work with this point layer and I want to remove all the Sg & Sgs labels from it: So I can get this result only: All the labels are in one field named "field_name" (...
2
votes
3answers
137 views

Parsing new field into calculate field

I have a pivot table that has 11 ShipTypeGroup fields with "Long" field properties that can't be divided by 12, due to decimal places. Therefore I am trying to create a new field, copy attributes ...
2
votes
2answers
102 views

Describing input field in ArcMap Field Calculator window?

A few days ago I was answering Comparing two fields and printing result as 1 (if number matches) or 0 (if not) using Python Parser of ArcGIS Field Calculator? When describing the process required ...
2
votes
3answers
3k views

How to get around “The field is not nullable” error?

I have a shapefile of lines. I want the angle of every line calculated in a field. I am using the script below in arcmap, but when it encounters a line that is horizontal, it stops calculating any ...
2
votes
1answer
184 views

Running ArcGIS field calculation using Python with algebraic expression using other field values as variables?

I'm trying to run a field calculation using multiple fields in a table as well as independent numeric values with python code in the field calculator window. I've included the first 7 lines of the ...
2
votes
1answer
319 views

Selecting numbers within the slash (/) using ArcMap Field Calculator?

I have date data that I'm separating into three separate fields (all fields are string type, including the input field) by day, month, and year. Unfortunately, the date field is raw data and isn't ...
2
votes
1answer
863 views

Using if else statement in Python Parser of Field Calculator in ArcGIS for Desktop?

I need help in writing the python script in the field calculator. I have three fields namely: CODE COMPLEX Map1 Map1 is an empty field that I want to populate. I have a number of conditions to cater ...
2
votes
2answers
624 views

Field Calculate with a function written in python within a larger python script

I'm writing a python program where I need to field calculate using a python function. The function takes two strings; one used for an if statement and the other to become an integer complete a simple ...
2
votes
1answer
650 views

Debugging error 000539 from ArcGIS Field Calculator?

What am I doing wrong in this field calculator logic? Pre-logic def re_score(elev_t,f2, contour): f2=contour if elev_t.endswith('.5'): f2 = "Midi" return f2 Expression for field "Contourtyp" ...
2
votes
1answer
1k views

Putting multiple lines of Python into ArcGIS 10's Field Calculator

Entering these lines of Python one at a time works like a charm... Just need one more seemingly simply issue solved... How do we place multiple lines of Python code into ArcGIS's Field Calculator ...
2
votes
1answer
2k views

Writing If-Then statement in ArcGIS Pro field calculator using Python?

I've been using ArcGIS Pro over ArcMap recently because ArcMap is giving me some incorrect summary statistics that I use to populate a data field in a number of feature classes. The problem is that I'...
2
votes
1answer
180 views

Using Simple Python Parser expression?

My level is very basic in Python. This is the python codeblock I have in ArcGIS Field Calculator: def Reclass(THLB): if THLB == 0: return 0 elif THLB == 1: return !Shape_Area! This ...
2
votes
1answer
432 views

Python labeling Expression how to change font size?

I have a labeling expression using two attributes I want the first one to be size 14 and the second one to be on a new line and be size 8. This was my attempt so far: "<FNT name='Arial' size='14'&...
2
votes
1answer
98 views

Populating new field based on existing string field using ArcGIS Field Calculator?

My programming is really rusty at this point, and I am trying to do a simple calculation using a Codeblock, either VB or Python is fine. I have tried about 50 different variations on same theme, and ...
2
votes
1answer
187 views

Using field calculator to auto-increment within a range?

I am trying to use field calculator to number points between -700 and 700. I have used this code block: rec=0 def autoIncrement(): global rec pStart = 700 pInterval = -1 if (rec == 0): ...
2
votes
1answer
495 views

Specifying Font Size/Style in Label Expression?

I want to create a label expression with two lines of text, this should be simple but I'm having a lot of trouble. Basically, I need the top line to be 10 pt font, and the next line to be 8pt font ...