-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathadifutil.py
46 lines (36 loc) · 1.13 KB
/
adifutil.py
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
#!/usr/bin/python
import datetime
import adif
def convert_qso_date(d):
return datetime.datetime.strptime(d, '%Y%m%d%H%M%S')
def safe_get(d, k):
result = d.get(k)
if result is None:
return ""
return result
def main():
fn = 'w1cum.adif'
start_of_contest = datetime.datetime.strptime("20190622180000", '%Y%m%d%H%M%S')
end_of_contest = datetime.datetime.strptime("20190623180000", '%Y%m%d%H%M%S')
qsos = adif.read_adif_file(fn)
band_totals = {}
num_qsos = 0
for qso in qsos:
dt = safe_get(qso, 'qso_date')
tm = safe_get(qso, 'time_on')
d = convert_qso_date(dt+tm)
if (d >= start_of_contest) and (d < end_of_contest):
num_qsos += 1
band = safe_get(qso, 'band')
if band_totals.get(band) is None:
band_totals[band] = 0
band_totals[band] += 1
print('%d qsos' % num_qsos)
bands = ['80m', '40m', '20m', '15m', '10m', '6m']
for band in bands:
bt = band_totals.get(band)
if bt is None:
bt = 0
print("%4s : %5d " % (band, bt))
if __name__ == '__main__':
main()