ConvertPCX5ToCSV

From Wurst-Wasser.net
Revision as of 20:19, 18 October 2010 by Heiko (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#!/bin/bash
#set -x

# Von pcx -> txt (comma-separated)
# (PCX-Format kann man zB von naturparkschwarzwald.de runterladen)

GINFILE="${1}"
test ! -f "${GINFILE}" && echo "Inputfile not found. Exiting." && exit 1 
GTRACKNAME="`echo ${GINFILE} | cut -d. -f1 | cut -c1-16`" 
GOUTFILE="${GTRACKNAME}.txt"
test -f "${GOUTFILE}" && echo "Outputfile exists. Exiting." && exit 1
touch "${GOUTFILE}"

cat "${GINFILE}" | grep "^T" | sed s/^T\ //\g | while read LAT LON DATE TIME ALT; do
      echo "${GTRACKNAME},${LAT},${LON},${ALT}" >> "${GOUTFILE}"
done