# Field Calculator, pulling data from string to new columns

404
4
05-18-2022 11:37 AM
Labels (1)
New Contributor

Using ArcMap 10.8.1.  I have a set of data I need to pull into 3 separate, new columns.   I have been successful with 2 of the pieces of data, but the 3rd is proving to be difficult.

The data in the column (the column is titled "Comment") is:  1, 59264, 0 , 12459

The first number is a location, the following 3 numbers are individual readings.

Mid ([Comment], 3, 6)   works for the 59264 number.

Right ([Comment], 5)   works for the 12459 number.

I can't nail down the statement for the 0 in this case.  Any ideas what that would need to read to pull that section out?

(The first number, 1 in this case, is irrelevant, its just a place holder generated by the instruments we use).

4 Replies
New Contributor II
The zero may be text versus numeric.
by
MVP Esteemed Contributor

You could split the input string and access the value by index.

``````var num_arr = Split(Replace(\$feature['Comment'], ' ', ''), ',')

return num_arr[2]``````

- Josh Carlson
Kendall County GIS
Frequent Contributor III

It can be done with creative instring calculations.

However, what I would do is export your Table, with opject id to a .csv.

Open the .csv in Excel.  Copy all attributes in the Field you need to scatter.

Copy it from notepad and paste it into Word.

In word do find replace and search for   Comma and Space and replace it with   ^t

This will spread your data in to four parts and remove the spaces.

The copy and paste the result from word back into your spreadsheet.

The bring your spreadsheet into your mxd, join it based on Object ID and update the columns.

If your in a personal  Geodatabase you could just paste the results of each column into the appropriate column.

Actually took me a lot longer to write this then it would take me to do it.

New Contributor

I appreciate all the help.  I was able to use a Python expression to split what I needed out.

(This is absolute baptism by fire for me, so my apologies if the questions seemed a bit off.  Again, thank you all for the help.)