SHOW:
|
|
- or go back to the newest paste.
| 1 | #!/bin/bash | |
| 2 | ||
| 3 | cat << EOF | |
| 4 | <?xml version="1.0" encoding="UTF-8"?> | |
| 5 | <gpx version="1.1" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"> | |
| 6 | <trk> | |
| 7 | <name>pojmenuj</name> | |
| 8 | <trkseg> | |
| 9 | EOF | |
| 10 | ||
| 11 | stringMin="-" | |
| 12 | stringT="T" | |
| 13 | stringColon=":" | |
| 14 | stringZ="Z" | |
| 15 | ||
| 16 | while read line | |
| 17 | do | |
| 18 | ||
| 19 | timestampHarsh=`echo "$line" | cut -d "," -f 1` | |
| 20 | timestampNice=`echo "$timestampHarsh" | cut -d ":" -f 2 | cut -d "." -f1 | tr -d '[[:space:]]'` | |
| 21 | rok=${timestampNice:0:4}
| |
| 22 | - | mesic=${timestampNice:5:1}
|
| 22 | + | mesic=${timestampNice:4:2}
|
| 23 | den=${timestampNice:6:2}
| |
| 24 | hod=${timestampNice:8:2}
| |
| 25 | min=${timestampNice:10:2}
| |
| 26 | sec=${timestampNice:12:2}
| |
| 27 | timestamp=$rok$stringMin$mesic$stringMin$den$stringT$hod$stringColon$min$stringColon$sec$stringZ | |
| 28 | ||
| 29 | lat=`echo "$line" | cut -d "," -f 2` | |
| 30 | lon=`echo "$line" | cut -d "," -f 3` | |
| 31 | ||
| 32 | ||
| 33 | echo "<trkpt lat=\"$lat\" lon=\"$lon\">" | |
| 34 | echo "<time>$timestamp</time>" | |
| 35 | echo "</trkpt>" | |
| 36 | ||
| 37 | ||
| 38 | #moje_csv.csv je hned vedle tohoto scriptu | |
| 39 | done < moje_csv.csv | |
| 40 | cat << EOF | |
| 41 | </trkseg> | |
| 42 | </trk> | |
| 43 | </gpx> | |
| 44 | EOF |