# This awk script is supposed to take the and pull out the data # for each line from the ASCII output of wind data ... # input data in "DD/MM/YYYY|DATA0|DATA1|... " format # output data in "MM |DATA0|DATA1|... " format # $1 = DAY # $2 = MONTH # $3 = YEAR # $4 = DATA BEGIN { FS = "[/|]" OFS = "\t" } { # NR = current record ALL[NR] = $0 DAY[NR] = $1 MONTH[NR] = $2 YEAR[NR] = $3 DATA0[NR] = $4 DATA1[NR] = $5 DATA2[NR] = $6 DATA3[NR] = $7 # N[NR] = split(ALL[NR], DATA, "[/|]") } { N = split($0, DATA, "[/|]") # print "N is", N, DATA[0], DATA[1], DATA[2], DATA[3], DATA[4] # Notify us if we don't have 24 hours of data if (N != 27) { printf("Data invalid, should have 27 fields but have %d\n",N) } # printf("Date: ") # for (i=1; i<=3; i++) { # printf("%s ", DATA[i]) # } # printf("\n") # print the Month printf("%s ", DATA[2]) # print the wind direction and wind speed for each hour for (i=4; i<=N; i++) { SLEN = length(DATA[i]) if (SLEN == 4) { printf("%.1s %.3s ", DATA[i], substr(DATA[i],SLEN-3+1,3)) } else if (SLEN == 5) { printf("%.2s %.3s ", DATA[i], substr(DATA[i],SLEN-3+1,3)) } else if (SLEN == 6) { printf("%.3s %.3s ", DATA[i], substr(DATA[i],SLEN-3+1,3)) } } printf("\n") }