Sep-23-2018, 11:12 PM
HI
I have a .adi file that looks like this:
<PROGRAMID:15>WWFFlog by 5p0o
<PROGRAMVERSION:4>5.04
<EOH>
***************** START OF NEW CALL: 5P0O
<OPERATOR:4>5P0O <STATION_CALLSIGN:9>OZ4WWFF/P <CALL:5>ON4CB <QSO_DATE:8>20170322 <TIME_ON:4>1508 <RST_SENT:2>59 <RST_RCVD:2>52 <BAND:3>80M <MODE:3>SSB <MY_SIG:9>OZFF-0175 <EOR>
<OPERATOR:4>5P0O <STATION_CALLSIGN:9>OZ4WWFF/P <CALL:5>OZ1QZ <QSO_DATE:8>20170322 <TIME_ON:4>1509 <RST_SENT:2>59 <RST_RCVD:2>41 <BAND:3>80M <MODE:3>SSB <MY_SIG:9>OZFF-0175 <EOR>
<OPERATOR:4>5P0O <STATION_CALLSIGN:9>OZ4WWFF/P <CALL:5>LX1CC <QSO_DATE:8>20170322 <TIME_ON:4>1512 <RST_SENT:2>59 <RST_RCVD:2>57 <BAND:3>80M <MODE:3>SSB <MY_SIG:9>OZFF-0175 <EOR>
<OPERATOR:4>5P0O <STATION_CALLSIGN:9>OZ4WWFF/P <CALL:6>SP8LEP <QSO_DATE:8>20170322 <TIME_ON:4>1513 <RST_SENT:2>52 <RST_RCVD:2>55 <BAND:3>80M <MODE:3>SSB <MY_SIG:9>OZFF-0175 <EOR>
I want to read and store with in my program.
My code look like this:
I have added some print.... to see that data is ok during running.
When I do the print on "loggen[i]" the 3 first entries are the same as the last appended.
What am I doing wrong?
I have a .adi file that looks like this:
<PROGRAMID:15>WWFFlog by 5p0o
<PROGRAMVERSION:4>5.04
<EOH>
***************** START OF NEW CALL: 5P0O
<OPERATOR:4>5P0O <STATION_CALLSIGN:9>OZ4WWFF/P <CALL:5>ON4CB <QSO_DATE:8>20170322 <TIME_ON:4>1508 <RST_SENT:2>59 <RST_RCVD:2>52 <BAND:3>80M <MODE:3>SSB <MY_SIG:9>OZFF-0175 <EOR>
<OPERATOR:4>5P0O <STATION_CALLSIGN:9>OZ4WWFF/P <CALL:5>OZ1QZ <QSO_DATE:8>20170322 <TIME_ON:4>1509 <RST_SENT:2>59 <RST_RCVD:2>41 <BAND:3>80M <MODE:3>SSB <MY_SIG:9>OZFF-0175 <EOR>
<OPERATOR:4>5P0O <STATION_CALLSIGN:9>OZ4WWFF/P <CALL:5>LX1CC <QSO_DATE:8>20170322 <TIME_ON:4>1512 <RST_SENT:2>59 <RST_RCVD:2>57 <BAND:3>80M <MODE:3>SSB <MY_SIG:9>OZFF-0175 <EOR>
<OPERATOR:4>5P0O <STATION_CALLSIGN:9>OZ4WWFF/P <CALL:6>SP8LEP <QSO_DATE:8>20170322 <TIME_ON:4>1513 <RST_SENT:2>52 <RST_RCVD:2>55 <BAND:3>80M <MODE:3>SSB <MY_SIG:9>OZFF-0175 <EOR>
I want to read and store with in my program.
My code look like this:
loggen = [] qsotom = {} x = 0 # garbage def key_ok(nøgle): if nøgle == 'OPERATOR' or nøgle == 'STATION_CALLSIGN' or nøgle == 'CALL' or nøgle == 'QSO_DATE' or nøgle == 'TIME_ON' or nøgle == 'RST_SENT' or nøgle == 'RST_RCVD' or nøgle == 'BAND' or nøgle == 'MODE' or nøgle == 'MY_SIG': return True else: return False def read_adif(filename): logg = [] qso = qsotom index = 0 with open(filename) as input_file: for line in input_file: try: if line.index('OPERATOR') > -1: qso_data = True except: qso_data = False if qso_data: #qso = qsotom arr = line.split('<') for txt in arr: txt2 = txt.split('>') txt3 = txt.split(':') try: print('t2={},t3={}'.format(txt2[1], txt3[0])) except: x = 0 try: if key_ok(txt3[0]) and txt3[0] != 'EOR>': qso[txt3[0]] = txt2[1].strip() elif txt3[0].strip() == 'EOR>': logg.append(qso) qso = qsotom index = index + 1 except: x = 0 # End of with return logg loggen = read_adif('20170322_16_05_28_OZ4WWFF-P_OZFF-0175.ADI') i = 0 while i < længde: print(loggen[i]) print('\n') i += 1
I have added some print.... to see that data is ok during running.
When I do the print on "loggen[i]" the 3 first entries are the same as the last appended.
What am I doing wrong?