Blog posts
Bio
By David Crowther
Question:
How can you remove characters from the end of a cell within QGIS?
Answer:
Using the QGIS Field Calculator you can run an update script that can remove a designated number of characters from any cell within your data.
For example I have a Planning Applications layer and would like to remove the last 3 values (App) from the Name field, to generate the value ‘Planning’ instead of Planning App.
Using the Field Calculator tool within the Attribute table, you can use a Substring query to remove the last 4 values (as you will likely want to remove the Space character as well).
Choose to update an existing field, in this case the ‘name’ field.
Then type the following text:
substr("name",0,-4)
This will update the current values in the ‘name’ field by removing 0 characters from the left and 4 characters from the right hand side of the field. After pressing OK, the script will run and the values will be updated with 4 characters removed from the right.
Comments
0 comments
Please sign in to leave a comment.