-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse.sh
executable file
·46 lines (43 loc) · 965 Bytes
/
parse.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
mkdir -p $1
cd $1
[ ! "$(ls -A ./)" ] && wget -q -nd -r ftp://amrc.ssec.wisc.edu/pub/requests/DVPC/AWS_q3h_MAY_2014/\*
cd ..
echo "["
find $1 -type f -exec awk '
BEGIN { printf "{" }
{
if (NR==1) {
printf "\"year\": " $2 ", "
printf "\"month\": " $4 ", "
printf "\"name\": \"" $10 "\", "
printf "\"id\": \"" $6 "\", "
printf "\"argos\": " $8 ", "
}
else if (NR==2) {
printf "\"lat\": \"" $2 "\"" ", "
printf "\"lon\": \"" $4 "\"" ", "
printf "\"elev\": \"" $6 "\"" ", "
printf "\"data\": ["
}
else {
if (NR > 3) printf ", "
printf "{"
printf "\"julian day\": " $2 ", "
printf "\"day\": " $4 ", "
printf "\"ten minute obs time\": " $5 ", "
printf "\"temp\": " $6 ", "
printf "\"pressure\": " $7 ", "
printf "\"wind speed\": " $8 ", "
printf "\"wind direction\": " $9 ", "
printf "\"humidity\": " $10
printf "}"
}
}
END {print "]}"}' '{}' ';' | \
awk '{
if (NR > 1) print ", "
printf $0;
}'
echo
echo "]"