Created
June 6, 2018 03:48
-
-
Save amicuscertus/834d6490d79c7d05fff0578e0b36ee04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import datetime | |
fnames = ['station1.adif', 'station2.adif'] | |
def parse_adif(fn): | |
raw = re.split('<eor>|<eoh>',open(fn).read() ) | |
raw.pop(0) | |
raw.pop() | |
logbook =[] | |
for record in raw: | |
qso = {} | |
tags = re.findall('<(.*?):\d+.*?>([^<\t\n\r\f\v]+)',record) | |
for tag in tags: | |
qso[tag[0]] = tag[1] | |
logbook.append(qso) | |
return logbook | |
def mydatetime(date, time): | |
dt = datetime.datetime(int(date[0:4]), int(date[4:6]), int(date[6:8]), \ | |
int(time[0:2]), int(time[2:4]), int(time[4:6])) | |
return dt | |
dt0 = datetime.datetime(2018, 6, 5, 9, 10, 44) | |
dt9 = datetime.datetime(2018, 6, 9, 23, 59, 59) | |
pattern1 = r"10" | |
pattern2 = r"Japan" | |
l1 = parse_adif(fnames[0]) | |
l2 = parse_adif(fnames[1]) | |
for qso1 in l1: | |
if ('FREQ' in qso1 and re.match(pattern1, qso1['FREQ' ])) and \ | |
('COUNTRY' in qso1 and re.match(pattern2, qso1['COUNTRY'])): | |
for qso2 in l2: | |
if (qso1['CALL'] in qso2.values()): | |
dt1 = mydatetime(qso1['QSO_DATE'], qso1['TIME_ON']) | |
dt2 = mydatetime(qso2['QSO_DATE'], qso2['TIME_ON']) | |
td = (dt1 - dt2).total_seconds() | |
if (abs(td) < 600 and \ | |
'APP_PSKREP_SNR' in qso1 and \ | |
'APP_PSKREP_SNR' in qso2): | |
print(qso1['APP_PSKREP_SNR'], qso2['APP_PSKREP_SNR'], td)_ | |
# end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment