Hi all,
I am looking to use geoprocessing tools or python script in ArcPro to identify numeric data (year) within cells of one attribute table column, pull the year and then populate a corresponding attribute table cell with that data. I've attached a screenshot example of the data for water pipe that I would look to use as a test.
I want to run the tool on a large number of records (over 12,000) have them identify and copy the four digit year from a project (district) description, then populate the 'year_inst' field with said number.
Is this feasible? Or at least a version of it that I could then QC? I would appreciate any and all feedback as I'm not looking forward to attempting to clean thousands upon thousands of attribute records.
Appreciate this community and any help offered.
Cheers,
-Matt
Solved! Go to Solution.
You could do a Python expression in the Calculate Field tool.
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field.htm
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field-examples.htm
To get the last 4 digits (the year) from the string, use string slicing.
https://stackoverflow.com/questions/7983820/get-the-last-4-characters-of-a-string
Set that equal to a variable, such as my_year, and then calculate the new field value as int(my_year) if the year field is int. If it's a date/time field you'll have to do a little more work, see the date time examples here.
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field-examples.htm
Matthew,
This is definitely feasible.
As you iterate over each record, you are extracting the last 4 characters from the 'DISTRICT' field and then updating the 'YR_INST' field with that data. You may need to typecast the year value to a number if the datatype of the 'YR_INST' field isn't a string.
Good luck
You could do a Python expression in the Calculate Field tool.
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field.htm
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field-examples.htm
To get the last 4 digits (the year) from the string, use string slicing.
https://stackoverflow.com/questions/7983820/get-the-last-4-characters-of-a-string
Set that equal to a variable, such as my_year, and then calculate the new field value as int(my_year) if the year field is int. If it's a date/time field you'll have to do a little more work, see the date time examples here.
https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field-examples.htm