1
1
// goadifstat: check statistics of ADIF ADI files
2
2
// by Kenji Rikitake, JJ1BDX
3
3
// Usage: goadifstat [-f infile] [-o outfile] -q query type
4
- // Valid query types: bands, country, dxcc, gridsquare, modes, nqso, submodes
4
+ // Valid query types: bands, country, cqz, dxcc, gridsquare, modes, nqso, submodes
5
5
6
6
package main
7
7
@@ -29,6 +29,7 @@ var bandList = []string{
29
29
30
30
var mapBand map [string ]int
31
31
var mapCountry map [string ]int
32
+ var mapCqz map [int ]bool
32
33
var mapDxcc map [int ]bool
33
34
var mapGrid map [string ]bool
34
35
var mapMode map [string ]int
@@ -37,6 +38,7 @@ var mapSubmode map[string]int
37
38
func initStatMaps () {
38
39
mapBand = make (map [string ]int )
39
40
mapCountry = make (map [string ]int )
41
+ mapCqz = make (map [int ]bool )
40
42
mapDxcc = make (map [int ]bool )
41
43
mapGrid = make (map [string ]bool )
42
44
mapMode = make (map [string ]int )
@@ -83,6 +85,23 @@ func updateStatMaps(record adifparser.ADIFRecord) {
83
85
}
84
86
}
85
87
88
+ // cqz
89
+ key , err = record .GetValue ("cqz" )
90
+ if err != nil && err != ErrNoSuchField {
91
+ fmt .Fprint (os .Stderr , err )
92
+ } else if key != "" {
93
+ // Cqz values are integers
94
+ keynum , err = strconv .Atoi (key )
95
+ if err != nil && err != ErrNoSuchField {
96
+ fmt .Fprint (os .Stderr , err )
97
+ } else {
98
+ _ , exists = mapCqz [keynum ]
99
+ if ! exists {
100
+ mapCqz [keynum ] = true
101
+ }
102
+ }
103
+ }
104
+
86
105
// dxcc
87
106
key , err = record .GetValue ("dxcc" )
88
107
if err != nil && err != ErrNoSuchField {
@@ -166,6 +185,16 @@ func statOutput(query *string, writer *bufio.Writer,
166
185
fmt .Fprintf (writer , "%s: %d\n " , k , mapCountry [k ])
167
186
}
168
187
fmt .Fprintln (writer , "(TOTAL):" , reader .RecordCount ())
188
+ case * query == "cqz" :
189
+ keys := make ([]int , 0 , len (mapCqz ))
190
+ for k := range mapCqz {
191
+ keys = append (keys , k )
192
+ }
193
+ sort .Ints (keys )
194
+ for _ , n := range keys {
195
+ fmt .Fprintf (writer , "%d " , n )
196
+ }
197
+ fmt .Fprintf (writer , "\n " )
169
198
case * query == "dxcc" :
170
199
keys := make ([]int , 0 , len (mapDxcc ))
171
200
for k := range mapDxcc {
@@ -227,7 +256,7 @@ func main() {
227
256
fmt .Fprintf (flag .CommandLine .Output (),
228
257
"Usage: %s [-f infile] [-o outfile] -q query type\n " , execname )
229
258
fmt .Fprintln (flag .CommandLine .Output (),
230
- "Valid query types: bands, country, dxcc, gridsquare, modes, nqso, submodes" )
259
+ "Valid query types: bands, country, cqz, dxcc, gridsquare, modes, nqso, submodes" )
231
260
flag .PrintDefaults ()
232
261
}
233
262
0 commit comments