|
@@ -323,8 +323,9 @@ def rowValid(df,r,pars):
|
|
|
def updateAndValidateEntry(e,pars):
|
|
def updateAndValidateEntry(e,pars):
|
|
|
return True
|
|
return True
|
|
|
|
|
|
|
|
-def generateEntries(df,r,getId,pars):
|
|
|
|
|
|
|
+def generateEntries(df,r,objFunc,pars):
|
|
|
idField=pars.get('idField','ParticipantId')
|
|
idField=pars.get('idField','ParticipantId')
|
|
|
|
|
+ getId=objFunc['getId']
|
|
|
id=getId(df,r,pars)
|
|
id=getId(df,r,pars)
|
|
|
entry={}
|
|
entry={}
|
|
|
entry[idField]=id
|
|
entry[idField]=id
|
|
@@ -352,12 +353,25 @@ def setParsingObject(pars):
|
|
|
print(f'aliases: {alias}')
|
|
print(f'aliases: {alias}')
|
|
|
return obj
|
|
return obj
|
|
|
|
|
|
|
|
|
|
+def setFuncObject(getId,modify,convertLookup,rowValid,updateAndValidateEntry):
|
|
|
|
|
+ obj={}
|
|
|
|
|
+ obj['getId']=getId
|
|
|
|
|
+ obj['modify']=modify
|
|
|
|
|
+ obj['convertLookup']=convertLookup
|
|
|
|
|
+ obj['rowValid']=rowValid
|
|
|
|
|
+ obj['updateAndValidateEntry']=updateAndValidateEntry
|
|
|
|
|
+ return obj
|
|
|
|
|
|
|
|
-def setEntry(entry,df,r,objParse,pMap,pars):
|
|
|
|
|
|
|
+def setEntry(entry,df,r,objParse,objFunc,pMap,pars):
|
|
|
|
|
|
|
|
additionalVars=pars.get('additionalVars',{})
|
|
additionalVars=pars.get('additionalVars',{})
|
|
|
seqNumOffset=pars.get('seqNumOffset',0)
|
|
seqNumOffset=pars.get('seqNumOffset',0)
|
|
|
idField=pars.get('idField','ParticipantId')
|
|
idField=pars.get('idField','ParticipantId')
|
|
|
|
|
+
|
|
|
|
|
+ modify=objFunc['modify']
|
|
|
|
|
+ convertLookup=objFunc['convertLookup']
|
|
|
|
|
+ updateAndValidateEntry=objFunc['updateAndValidateEntry']
|
|
|
|
|
+
|
|
|
eId=entry[idField]
|
|
eId=entry[idField]
|
|
|
|
|
|
|
|
for v in df.columns:
|
|
for v in df.columns:
|
|
@@ -443,6 +457,7 @@ def importData(pars,filename,getId=getId,modify=modify,\
|
|
|
updateAlias=pars.get('updateAlias',lambda x,y: x)
|
|
updateAlias=pars.get('updateAlias',lambda x,y: x)
|
|
|
copyColumns=pars.get('copyColumns',{})
|
|
copyColumns=pars.get('copyColumns',{})
|
|
|
|
|
|
|
|
|
|
+ objFunc=setFuncObject(getId,modify,convertLookup,rowValid,updateAndValidateEntry)
|
|
|
objParse=setParsingObject(pars)
|
|
objParse=setParsingObject(pars)
|
|
|
|
|
|
|
|
df=pandas.read_excel(filename,sheet_name=sheet_name,skiprows=skiprows,\
|
|
df=pandas.read_excel(filename,sheet_name=sheet_name,skiprows=skiprows,\
|
|
@@ -462,9 +477,10 @@ def importData(pars,filename,getId=getId,modify=modify,\
|
|
|
for r in idx:
|
|
for r in idx:
|
|
|
if not rowValid(df,r,pars):
|
|
if not rowValid(df,r,pars):
|
|
|
continue
|
|
continue
|
|
|
- rowEntries=generateEntries(df,r,getId,pars)
|
|
|
|
|
|
|
+ rowEntries=generateEntries(df,r,objFunc,pars)
|
|
|
|
|
+
|
|
|
for e in rowEntries:
|
|
for e in rowEntries:
|
|
|
- e=setEntry(e,df,r,objParse,pMap,pars)
|
|
|
|
|
|
|
+ e=setEntry(e,df,r,objParse,objFunc,pMap,pars)
|
|
|
if e==None:
|
|
if e==None:
|
|
|
continue
|
|
continue
|
|
|
|
|
|