Saturday, 27 May 2017

How to split a text attribute by characters in QGIS 2.6.0


Is it possible to make a new column, for example named "Test" and store the first part of the column "Name" split by -?


See below how it should look like:


enter image description here



Answer



Yes you can.



Use the Field calculator with the following expression:


left( "Name", strpos( "Name" ,'-'))

The strpos() function will return the index position of the first '-' character and the left() function "trims" the string before that position.


enter image description here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...