Tags: Unix, AWK, WSPR

Posted: April 6, 2012

Making sense of WSPR CSV files

For various reasons I’ve been searching through downloaded WSPR spot databases by hand today. The downloads are provided in a simple CSV format that’s very easy to work with. The only difficulty is the Unix timestamp in the second field; while this is very convenient when processing the file, it isn’t exactly easy to read.

To save myself working it out again next time, the following bit of gawk(1) magic converts the output to something readable:

gawk -F, 'BEGIN {OFS="\t"} {printf "%s", strftime("%F %H:%M",$2,1); $1=""; $2=""; print}'

Before:

$ head -n 3 wsprspots-2011-12.csv
77775807,1322697600,4Z4TI,KM71jg,-24,10.140252,F6BIA,JN18dq,33,0,3339,113,10,2.11_r2263,0
77775839,1322697600,W1BW,FN42hl,-25,10.140257,F6BIA,JN18dq,33,0,5548,292,10,3.00_r2436,0
77775830,1322697600,G4ZFQ,IO90ir,-18,5.288683,G3THQ,IO91un,37,0,116,217,5,3.00_r2309,0

After:

head -n 3 wsprspots-2011-12.csv |  gawk -F, 'BEGIN {OFS="\t"} {printf "%s", strftime("%F %H:%M",$2,1); $1=""; $2=""; print}'
2011-12-01 00:00        4Z4TI   KM71jg  -24 10.140252   F6BIA   JN18dq 33  0   3339    113 10  2.11_r2263  0
2011-12-01 00:00        W1BW    FN42hl  -25 10.140257   F6BIA   JN18dq 33  0   5548    292 10  3.00_r2436  0
2011-12-01 00:00        G4ZFQ   IO90ir  -18 5.288683    G3THQ   IO91un 37  0   116 217 5   3.00_r2309  0

Note that it does have to be gawk; the strftime() function is a GNU extension not found in POSIX AWK.