Select to view content in your preferred language

***Field Calculator Help*** How to pad a string with periods to fit remaining field length

290
13
Jump to solution
Thursday
JM32
by
Frequent Contributor

Hi Everyone,

I'm trying to create a nice road index for a map. One that looks like the screenshot below. However, I can't figure out how to create the index so that my road name listed has periods filling in the remaining space before the index cell is listed.

So far, I found some examples of python to use but nothing specific to how to enter it into the field calculator in ArcGIS Pro. The table shows my two fields, one with the street name, the other with the index cell it falls in on my map.

Any help is appreciated!

Index example.png

table example.png

  

0 Kudos
13 Replies
ChrisUnderwood
Esri Regular Contributor

Hello @JM32 , something like this will work in the Field Calculator without a Code Block if you prefer.

!COUNTRY!+("..............."[:(15-(len(!COUNTRY!)))])+str(!MYINT!)

ChrisUnderwood_1-1746117116467.png

 

 

 

JM32
by
Frequent Contributor

@ChrisUnderwood This worked, but the result is the same as above where I get uneven columns. The first screenshot in my initial post is my goal. I'd like to have the road names listed, and then have dots until the index cell is listed, but have them all line up together. Hopefully this makes sense!

0 Kudos
DanPatterson
MVP Esteemed Contributor

perhaps a monospaced font would have to be specified, which is probably an unlikely case for field calculations.

 


... sort of retired...
JM32
by
Frequent Contributor

Success! So, the solution is from both @TonyAlmeida and @DanPatterson 

Below are screenshots of the results and field calculator expression used. 

The expression allowed for me to set a number for how many dots I'd like with the remaining space in a given text field. After running it, I still had alignment issues. However, I switch to a monospaced font (Courier New) and everything aligned perfectly! I plan to use this to create the final road index I'm making for a street map. 

Thank you everyone for your help!

Jon

Success_index.png

Success_CalculatorView.png