forked from expo/troggle
import diagnostics
This commit is contained in:
parent
5d7d2b82b2
commit
87fd260051
@ -55,8 +55,8 @@ def parseCaveQMs(cave,inputFile):
|
|||||||
message = f' ! - {qmPath} KH is not in the database. Please run cave parser'
|
message = f' ! - {qmPath} KH is not in the database. Please run cave parser'
|
||||||
print(message)
|
print(message)
|
||||||
DataIssue.objects.create(parser='QMs', message=message)
|
DataIssue.objects.create(parser='QMs', message=message)
|
||||||
parse_KH_QMs(kh, inputFile=inputFile)
|
nqms = parse_KH_QMs(kh, inputFile=inputFile)
|
||||||
return
|
return nqms
|
||||||
|
|
||||||
#qmPath = settings.EXPOWEB+inputFile
|
#qmPath = settings.EXPOWEB+inputFile
|
||||||
qmPath = os.path.join(settings.EXPOWEB, inputFile)
|
qmPath = os.path.join(settings.EXPOWEB, inputFile)
|
||||||
@ -67,6 +67,7 @@ def parseCaveQMs(cave,inputFile):
|
|||||||
qmReader = csv.reader(qmCSVContents,dialect=dialect)
|
qmReader = csv.reader(qmCSVContents,dialect=dialect)
|
||||||
next(qmReader) # Skip header row
|
next(qmReader) # Skip header row
|
||||||
n = 0
|
n = 0
|
||||||
|
nqms = 0
|
||||||
for line in qmReader:
|
for line in qmReader:
|
||||||
try:
|
try:
|
||||||
n += 1
|
n += 1
|
||||||
@ -111,7 +112,7 @@ def parseCaveQMs(cave,inputFile):
|
|||||||
|
|
||||||
except QM.DoesNotExist: #if there is no pre-existing QM, save the new one
|
except QM.DoesNotExist: #if there is no pre-existing QM, save the new one
|
||||||
newQM.save()
|
newQM.save()
|
||||||
|
nqms += 1
|
||||||
except KeyError: #check on this one
|
except KeyError: #check on this one
|
||||||
message = f' ! - {qmPath} KeyError {str(line)} '
|
message = f' ! - {qmPath} KeyError {str(line)} '
|
||||||
print(message)
|
print(message)
|
||||||
@ -122,12 +123,14 @@ def parseCaveQMs(cave,inputFile):
|
|||||||
print(message)
|
print(message)
|
||||||
DataIssue.objects.create(parser='QMs', message=message)
|
DataIssue.objects.create(parser='QMs', message=message)
|
||||||
continue
|
continue
|
||||||
|
return nqms
|
||||||
|
|
||||||
def parse_KH_QMs(kh, inputFile):
|
def parse_KH_QMs(kh, inputFile):
|
||||||
"""import QMs from the 1623-161 (Kaninchenhohle) html pages, different format
|
"""import QMs from the 1623-161 (Kaninchenhohle) html pages, different format
|
||||||
"""
|
"""
|
||||||
khQMs=open(os.path.join(settings.EXPOWEB, inputFile),'r')
|
khQMs=open(os.path.join(settings.EXPOWEB, inputFile),'r')
|
||||||
khQMs=khQMs.readlines()
|
khQMs=khQMs.readlines()
|
||||||
|
nqms = 0
|
||||||
for line in khQMs:
|
for line in khQMs:
|
||||||
res=re.search(r'name=\"[CB](?P<year>\d*)-(?P<cave>\d*)-(?P<number>\d*).*</a> (?P<grade>[ABDCV])<dd>(?P<description>.*)\[(?P<nearest_station>.*)\]',line)
|
res=re.search(r'name=\"[CB](?P<year>\d*)-(?P<cave>\d*)-(?P<number>\d*).*</a> (?P<grade>[ABDCV])<dd>(?P<description>.*)\[(?P<nearest_station>.*)\]',line)
|
||||||
if res:
|
if res:
|
||||||
@ -151,10 +154,16 @@ def parse_KH_QMs(kh, inputFile):
|
|||||||
}
|
}
|
||||||
|
|
||||||
save_carefully(QM,lookupArgs,nonLookupArgs)
|
save_carefully(QM,lookupArgs,nonLookupArgs)
|
||||||
|
nqms += 1
|
||||||
|
return nqms
|
||||||
|
|
||||||
|
|
||||||
def Load_QMs():
|
def Load_QMs():
|
||||||
deleteQMs()
|
deleteQMs()
|
||||||
parseCaveQMs(cave='204-steinBH',inputFile=r"1623/204/qm.csv")
|
n204 = parseCaveQMs(cave='204-steinBH',inputFile=r"1623/204/qm.csv")
|
||||||
parseCaveQMs(cave='234-Hauch',inputFile=r"1623/234/qm.csv")
|
n234 = parseCaveQMs(cave='234-Hauch',inputFile=r"1623/234/qm.csv")
|
||||||
parseCaveQMs(cave='161-KH', inputFile="1623/161/qmtodo.htm")
|
n161 = parseCaveQMs(cave='161-KH', inputFile="1623/161/qmtodo.htm")
|
||||||
#parseCaveQMs(cave='balkonhoehle',inputFile=r"1623/264/qm.csv")
|
#parseCaveQMs(cave='balkonhoehle',inputFile=r"1623/264/qm.csv")
|
||||||
|
print(f" - Imported: {n204} QMs for 204, {n234} QMs for 234, {n161} QMs for 161.")
|
||||||
|
|
||||||
|
print ()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user