Download and compare ADIF files from PSK Reporter (2)

You may wish to compare the SNR values if the same DX stations are received both by you and your neighbour almost at the same time.

import re
 
file_name1 = 'mystation.adif'
file_name2 = 'hisstation.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[2]
        logbook.append(qso)    
    return logbook
 
l1 = parse_adif(file_name1)
l2 = parse_adif(file_name2)

pattern = r"7."

for qso in l1:
    if re.match(pattern, qso['FREQ']):
        for hisqso in l2:
            if (qso['CALL'] in hisqso.values()):
                if (qso['QSO_DATE'] == hisqso['QSO_DATE']):
                    mytime  = int(qso['TIME_ON'])
                    histime = int(hisqso['TIME_ON'])
                    if (abs(mytime - histime) < 2000):
                        print(qso['APP_PSKREP_SNR'], ', ', hisqso['APP_PSKREP_SNR'])
% python3 adif_parse.py  > data.csv
% R
> data=read.csv("data.csv")
> plot(data, tck=1, col="red", xlim=c(-30,20), ylim=c(-30,20))