[GRASS-dev] Parsing output of r.category which includes labels

Nikos Alexandris nik at nikosalexandris.net
Sun Aug 19 13:19:12 PDT 2018

If I am not wrong, all use cases of `read_command()` [0, 1],
in (at least) the grass-addons repository, do not consider an output
from `r.category` which includes labels.

[0] https://grass.osgeo.org/grass74/manuals/libpython/script.html?highlight=read_command#script.core.read_command
[1] https://grass.osgeo.org/grass75/manuals/libpython/script.html?highlight=read_command#script.core.read_command

I work on such a case where category numbers come along with label strings.
To read category numbers, I came up with:

import grass.script as grass
grass.read_command('r.category', map=base).split('\n')[:-1]

for category in categories:
        category = category.split('\t')[0]

Is there any other command that will do this better? Would you consider
adding one?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20180819/e9aa736b/attachment.sig>

More information about the grass-dev mailing list