2012-01-14

grass gis batch rename

Usually I dont like to do similar things multiple times. Like file or any object renaming.
Current problem involves Grass GIS database binded to vector layer. multiple columns has name as ID which doesn`t give much sense what exactly is stored in the column. Yet I know, that I have 14 columns with name dbl_1, dbl_2 and so on till dbl_14. The first two represents coordinates, and other 12 - monthly values. I would like to rename existing ID representing names to month names.
For such manipulation I need an array with month names. Then it is possible to iterate through the loop and in each iteration rename exact column.
Example is here - http://pastebin.com/52fMqL9j

Firstly the month names are passed as a simple string delimited with semicol ";"
Secondly, the string is splitted creating an array echoing and pipelining created string to bash tr comand (translate)
And then comes a loop over an created array. Counter "i" starts from value=3 because in my case the first id which represents the first monthly value is dbl_3 and it represents an october
In the loop the iterator increments through pipeline to bc

Nav komentāru:

Komentāra publicēšana