Removing Leading Numbers From a Field

3599
22
04-28-2022 06:50 AM
jfkuhn
by
New Contributor

I have a tracts field (Tract) which I want to strip off the first 4 numbers in an attribute table.  I created a new field (Tract2) for it.  I've tried several commands without success using the field calculator.  I'm receiving errors 

0 Kudos
22 Replies
curtvprice
MVP Esteemed Contributor

Tract codes are digits, but they must be text to do a join to another table that has a tract text field.  To create a text field Add a field "tract1" as type text, and populate it with Calculate Field (python syntax: str(int(!TRACT!) to a) make it integer and b) convert to text)

Getting data to load as text from a csv is tricky, the usual method is to add a row of dummy data to force type, for example put "aaaaaa" in the place of the tract column. The csv type issue is similar to issues loading data from excel https://pro.arcgis.com/en/pro-app/latest/help/data/excel/work-with-excel-in-arcgis-pro.htm

I think we have helped you as much as you can until you have data in text.

0 Kudos
jfkuhn
by
New Contributor

I did manage to get the data in string format (6 characters in length).  When clicking on validate join it says that everything is good. So I click to join the tables. When I open the Census Tract data I get an error when opening the attribute table of Invalidate Sql Statement Was Used.

0 Kudos
jfkuhn
by
New Contributor

Here the data that I'm trying to join to Census Tract file. 

https://oehha.ca.gov/calenviroscreen/report/calenviroscreen-40  (I downloaded the shape file)

The reason I'm doing it as the CES tract boundaries are more general and when overlaying Tiger line state/counties there's not a perfect alignment of boundaries like there should be.

0 Kudos