[GRASS-dev] RE: v.in.gpsbabel nearly fixed: awk magic needed (RT
bug#5478)
Markus Neteler
neteler at itc.it
Fri May 11 13:02:45 EDT 2007
Hi,
in similar form I have submitted this now. v.in.gpsbabel no longer crashes!
To figure out: are the attributes shifted by one row or not?
Markus
Patton, Eric wrote:
>
> How about this?
>
> head -2 Markus.txt | awk -F'\t' '{
> if($3 == ""){$3 = "NULL"}
> if($4 == ""){$4 = "NULL"}
> if($6 == ""){$6 = "NULL"}
> if($7 == ""}{$7 = "NULL"}
>
> printf("echo \"INSERT INTO $NAME VALUES (%d, ^%s^, %s, %s, ^%s^, %s, %s)\"
> | db.execute\n", $1, $2, $3, $4, $5, $6, $7) }' | tr '^' \'
>
> ;)
>
> ~ Eric.
>
> -----Original Message-----
> From: grass-dev-bounces at grass.itc.it on behalf of Markus Neteler
> Sent: Thu 5/10/2007 6:00 PM
> To: GRASS developers list
> Cc: grass-bugs at intevation.de
> Subject: [GRASS-dev] v.in.gpsbabel nearly fixed: awk magic needed (RT
> bug#5478)
>
> HI,
>
> I think I got v.in.gpsbabel for tracks and routes (did that
> ever work?). However, I have a final problem which requires
> a bit of awk magic:
>
> The GPX tracks file extracted from my Garmin contains a track
> which isn't attributed (I dunno why but that's life). The
> v.in.gpsbabel scripts successfully creates the map, then fails
> on creating the attrib table. Here the problem:
>
>
> # note: files contains tab delimiters
> head -2 12021.0.track_atts
> 1
> 2 45.417394638 10.847196579 45.359029770
> 10.166580677
>
>
> # make tab delim visible (just for illustration):
> head -2 12021.0.track_atts | tr -s '\t' '|'
> 1 | | | | | |
> 2 | |45.417394638 |10.847196579 | |45.359029770 |10.166580677
>
>
> # this is what happens in v.in.gpsbabel (note: it does cat instead of
> head):
> head -2 12021.0.track_atts | awk -F'\t' '{ printf("echo \"INSERT INTO
> $NAME VALUES (%d, ^%s^, %s, %s, ^%s^, %s, %s)\" | db.execute\n", $1, $2,
> $3, $4, $5, $6, $7) }' | tr '^' \'
> echo "INSERT INTO $NAME VALUES (1, ' ', , , ' ', , )" | db.execute
> echo "INSERT INTO $NAME VALUES (2, ' ', 45.417394638 , 10.847196579 , ' ',
> 45.359029770 , 10.166580677)" | db.execute
>
>
> We see that the first line isn't valid SQL. The first line should be:
> echo "INSERT INTO $NAME VALUES (1, ' ', NULL , NULL , ' ', NULL , NULL)"
> | db.execute
>
> Question: what to ask in the awk line to autoinsert NULL if 0 length is
> found in the numeric columns 3, 4, 6, 7?
>
> thanks
> Markus
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev
>
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev
>
>
--
View this message in context: http://www.nabble.com/v.in.gpsbabel-nearly-fixed%3A-awk-magic-needed-%28RT-bug--5478%29-tf3724138.html#a10435856
Sent from the Grass - Dev mailing list archive at Nabble.com.
More information about the grass-dev
mailing list