[GRASS-user] use pipe character in a script

Hello,

I try to fill a certain attribute column with a variable plus a Pipe character (|) in a python script:

value_to_fillin = myvariable + ‘|’

grass.run_command(‘v.db.update‘, map=‘mymap’, column=‘mycol’, value=value_to_fillin)

But it does not work. When I try to place there ‘xx’ instead of the pipe, it works.

Does the pipe have special meaning in Python or GRASS and therefore is not available as normal character? Is there a workaround (because the pipe must be there to meet my data transfer requirements)

Regards, Uwe

On Wed, Mar 23, 2022 at 8:59 AM Uwe Fischer <gisfisch@t-online.de> wrote:

Hello,

I try to fill a certain attribute column with a variable plus a Pipe character (|) in a python script:

value_to_fillin = myvariable + ‘|’

grass.run_command(‘v.db.update‘, map=‘mymap’, column=‘mycol’, value=value_to_fillin)

This works for me:

import grass.script as gs
valuetofillin = “myvariable{}”.format(‘a’)
gs.run_command(‘v.db.update’, map=‘aaa’, column=‘aa’, value=valuetofillin)

Btw, make sure to use the right single quotation marks around v.db.update. In your example, you are using pretty print quotation marks around v.db.update, so perhaps that is the culprit?

But it does not work. When I try to place there ‘xx’ instead of the pipe, it works.

Does the pipe have special meaning in Python or GRASS and therefore is not available as normal character? Is there a workaround (because the pipe must be there to meet my data transfer requirements)

Regards, Uwe


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

On Fri, Apr 1, 2022 at 10:26 AM Paulo van Breugel <p.vanbreugel@gmail.com> wrote:

On Wed, Mar 23, 2022 at 8:59 AM Uwe Fischer <gisfisch@t-online.de> wrote:

Hello,

I try to fill a certain attribute column with a variable plus a Pipe character (|) in a python script:

value_to_fillin = myvariable + ‘|’

grass.run_command(‘v.db.update‘, map=‘mymap’, column=‘mycol’, value=value_to_fillin)

This works for me:

import grass.script as gs
valuetofillin = “myvariable{}”.format(‘a’)
gs.run_command(‘v.db.update’, map=‘aaa’, column=‘aa’, value=valuetofillin)

Sorry, that should have been:

valuetofillin = “myvariable{}”.format(‘|’)
gs.run_command(‘v.db.update’, map=‘aaa’, column=‘aa’, value=valuetofillin)

Btw, make sure to use the right single quotation marks around v.db.update. In your example, you are using pretty print quotation marks around v.db.update, so perhaps that is the culprit?

But it does not work. When I try to place there ‘xx’ instead of the pipe, it works.

Does the pipe have special meaning in Python or GRASS and therefore is not available as normal character? Is there a workaround (because the pipe must be there to meet my data transfer requirements)

Regards, Uwe


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user