[GRASS-user] update column w/ output from bash function

Blumentrath, Stefan Stefan.Blumentrath at nina.no
Wed Jan 11 11:24:18 PST 2017


Hi Ken,

Why not using SQLites datetime functions directly: https://www.sqlite.org/lang_datefunc.html?
Should work in db.select or at least db.execute...

Cheres,
Stefan

-----Original Message-----
From: grass-user [mailto:grass-user-bounces at lists.osgeo.org] On Behalf Of Ken Mankoff
Sent: onsdag 11. januar 2017 18.54
To: grass-user at lists.osgeo.org
Subject: [GRASS-user] update column w/ output from bash function

Hi List,

I have a DB with a columns JD and YMD (julian day, and a varchar for a better date string format). I have a bash function for the conversion. I'm having trouble figuring out how to populate the YMD column.

Conversion function:

jul2ymd () { gdate -d "$1-01-01 +$2 days -1 day" "+%Y-%m-%d"; }

Neither db.execute nor db.select appear to work with arbitrary bash commands. I's there some way to do something similar to the following to fill the new column?

v.db.update map=DB column=YMD value=$(jul 2015 $(v.db.select map=DB column=JD))

I can imagine a scenario where I loop over every row and then use v.db.update and the VALUE option, but that seems inefficient.

Thanks,

  -k.


_______________________________________________
grass-user mailing list
grass-user at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


More information about the grass-user mailing list