Select to view content in your preferred language

Calculate Field returning blank values

516
0
06-23-2022 01:05 PM
MasonMTCCarter
New Contributor

Hello,

I am pulling information from a KML file that has been converted to layer form. Obviously, when this is done, all of the embedded HTML data is placed into a "Popupinfo" field. To extract the information I need, I wrote multiple Python expressions to be used in the calculate field tab, however I am running into an issue when attempting to run my code.

When running it from the terminal on a regular text file, I get the results expected. However, running the code in ArcGIS Pro throws up an error when it attempts to write "" or blank lines to every field, which causes it to fail as the field is float.

In a nutshell, what my code does is scan through to a certain line within the field, removes all 'illegal' characters, then outputs just the numbers and the decimal point. I would appreciate any help with this, thank you. 

Here is my Python code:

import linecache, re
def FindLegendMeasurment(input😞
    correctline = (linecache.getline(input, 64))
    correctnum = re.sub("[^0-9^.]", "", correctline)
    return float(correctnum)
 
 

Attached is a text file containing the popupinfo field.

0 Kudos
0 Replies