Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix TX_PWR entries in Log4OM SQLite database by importing values from WSJT-X ADIF
#!/usr/bin/env python
#
# by Sascha, DK9SAS
# Fixes TX power DB enties in SQLite DB by reading from an already imported
# WSJT-X ADIF file.
# (Necessary bc WSJT-X 1.9.1 exports TX_PWR incorrectly with the unit (W))
#
##############################################################################
# Imports
import re
import sqlite3
dbconn = sqlite3.connect('DK9SAS Log DB.SQLite')
dbcursor = dbconn.cursor()
with open('wsjtx_log.adi') as f:
for line in f:
m = re.search('<call:[0-9]+>(.*) <gr', line)
if m is not None:
call = m.group(1)
m = re.search('<time_on:6>([0-9]{6})', line)
timeon = m.group(1)
m = re.search('<time_off:6>([0-9]{6})', line)
timeoff = m.group(1)
m = re.search('<qso_date:8>([0-9]{8})', line)
qsodate = m.group(1)
m = re.search('<tx_pwr:[0-9]>([0-9]+)', line)
txpwr = m.group(1)
query = "UPDATE Log SET TXPwrDecimal = %s WHERE QSODate = \"%s\" AND TimeOn = \"%s\" AND TimeOff = \"%s\" AND Call = \"%s\" AND TXPwrDecimal = 0" % (txpwr, qsodate, timeon, timeoff, call)
print query
if call is not None:
dbcursor.execute(query)
dbconn.commit()
dbconn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.