Created
June 2, 2019 09:29
-
-
Save RipperFox/6e8bf75d99e927203c3e78eaf23f8329 to your computer and use it in GitHub Desktop.
This file contains 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
@@ -0,0 +1,41 @@ | |
#!/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 I once added the unit (W) in the TX_PWR field - shouldn't have done this, need to remove it now) | |
# | |
############################################################################## | |
# 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