changed variable interpolation to be useable in connection with dictionary definitions for formulas. Slightly less efficient but now much more powerful...
This commit is contained in:
parent
a5d5608063
commit
0885ea8023
|
@ -89,8 +89,8 @@ for file in files:
|
|||
|
||||
for label,formula in zip(options.labels,options.formulas):
|
||||
interpolator = []
|
||||
for position,column in enumerate(set(re.findall(r'#(.+?)#',formula))): # loop over unique set of column labels in formula
|
||||
formula = formula.replace('#'+column+'#','{%i}'%position)
|
||||
for column in re.findall(r'#(.+?)#',formula): # loop over column labels in formula
|
||||
formula = formula.replace('#'+column+'#','%f')
|
||||
if column in specials:
|
||||
interpolator += ['specials["%s"]'%column]
|
||||
elif column.isdigit():
|
||||
|
@ -107,7 +107,7 @@ for file in files:
|
|||
brokenFormula[label] = True
|
||||
|
||||
if label not in brokenFormula:
|
||||
evaluator[label] = "'" + formula + "'.format(" + ','.join(interpolator) + ")"
|
||||
evaluator[label] = "'" + formula + "'%(" + ','.join(interpolator) + ")"
|
||||
|
||||
# ------------------------------------------ calculate one result to get length of labels ------
|
||||
table.data_read()
|
||||
|
|
Loading…
Reference in New Issue