When I run the field calculator using VB Script, I don't get the desired result
field=
[field2]&".tif"
results in field2 .tif
instead of field2.tif
What can I do to eliminate that space? I have over 400 records, I'd prefer not to manually remove the space.
Solved! Go to Solution.
Use the python parser
# use the python parser
"{}.tif".format(!YourFieldName!.strip())
# or
!YourFieldName!.strip() + ".tif"
Use the python parser
# use the python parser
"{}.tif".format(!YourFieldName!.strip())
# or
!YourFieldName!.strip() + ".tif"
I also found another example that required pre-logic script code that worked:
Pre-Logic Script Code:
a1 = LTrim( [Label] )
a2 = RTrim( a1 )
plat=
a2&".tif"
BUT, your example is much simpler. It is what I will use in model builder as I will have to do this on a regular basis. I get the feature class from the county and so I simply replace my previous version with the new version but have to run a model in order to get the information I want each time. Thanks Dan!
Josh...glad it worked
python and the python parser have loads more options than the vb offerings... time to move forward
The python parser also includes math functions as well and inside of PRO they offer some code block options like if-else statement setup. Worth spending a few minutes with fields of various types and seeing what is available from within the mini- scrollable function list when python parser is selected
Actually, one more question. I've noticed that I have spaces in the file name and Chrome is inconsistent on how it handles the spaces
My result: BITTLES'S 2ND ADDITION.tif
url results: /BITTLES'S%202NDADDITION.tif
I would have expected /BITTLES'S%202ND%20ADDITION.tif
So, I'm guessing my results will be more consistent if I had a way to remove all spaces.
Never use spaces either use CamelCaseForFileNames or use Underscores_for_filenames
I agree, just not sure how to keep the proper names unless I use an alternate table and join it as part of a script which may be the best option. Maybe I can also use several concatenates in a string.
If you are using Pro, I have a toolset that has one multi-field concatenation tool. The coding is fairly simple
I've decided there isn't a simple way to do this. It all has to do with the original data. If each word was in a separate field, I could make this work and there is a way I could do that, but at some point, time spent building the script ends up taking more time than dealing with this manually. The data creator is also doing me no favors by having little consistency in naming conventions and properly filling in all of the data.
UPDATE: I've decided just to take over maintenance of this layer. I have a good enough handle on the data, I can maintain the layer the way I want to. The county will still handle my parcels and their data is still authoritative so I can still refer to it as needed. Thanks Dan for trying to help, your ideas would work in most situations.