|
@@ -53,6 +53,7 @@ def getFields(pars):
|
|
|
try:
|
|
|
dsgnFields[f].update({x:mdFields[f][x] for x in copyFields})
|
|
|
except KeyError:
|
|
|
+# print('{}: {}'.format(p,len(pMap[p])))
|
|
|
pass
|
|
|
return dsgnFields
|
|
|
|
|
@@ -313,17 +314,17 @@ def convertLookup(xlsColumnName):
|
|
|
def rowValid(df,r):
|
|
|
return True
|
|
|
|
|
|
-def updateEntry(e):
|
|
|
- pass
|
|
|
+def updateAndValidateEntry(e):
|
|
|
+ return True
|
|
|
|
|
|
def importData(pars,filename,getId=getId,modify=modify,\
|
|
|
convertLookup=convertLookup,dryRun=True,debug=True,
|
|
|
- rowValid=rowValid,updateEntry=updateEntry):
|
|
|
+ rowValid=rowValid,updateAndValidateEntry=updateAndValidateEntry):
|
|
|
#master routine that imports data based on pars,
|
|
|
#applies user supplied functions modify, convertLookup and get Id and
|
|
|
#updates relevant database
|
|
|
#rowValid signals a valid row, argument is current row from xlsx
|
|
|
-#updateEntry adds fields that can be computed from other fields in entry
|
|
|
+#updateAndValidateEntry can add fields that can be computed from other fields in entry and allows to reject entries not matching a target pattern
|
|
|
|
|
|
#some useful fields from pars (d is for default value)
|
|
|
# - skiprows removes irelevant rows (number, d: 0)
|
|
@@ -420,7 +421,9 @@ def importData(pars,filename,getId=getId,modify=modify,\
|
|
|
entry['Date']=entry[dateVariable]
|
|
|
except KeyError:
|
|
|
pass
|
|
|
- updateEntry(entry)
|
|
|
+
|
|
|
+ if not updateAndValidateEntry(entry):
|
|
|
+ continue
|
|
|
|
|
|
entries.append(entry)
|
|
|
|