Hey all,
How do I add another index inside a re.search?
I want to add
for j in [96,97,98,99]
BASE = re.search ...
sh.Cells97...
for i ....
so that the Table 96 within the re.search(s) becomes Table 96, Table 97, Table 98, Table 99
but don't know how to add a second index within the re.search since I already have %char
in match = re.search ... " %char, neuro ...
VAR=[]
BASE = re.search("Tabl e 96.*?BASE.*?\d( .*?)\n", neuro, re.S ).group(1).spli t()[1]
sh.Cells(7,last col+1).Value = BASE
for i, char in enumerate(["RECEIVED E", "PARTICIPAT ED "]):
match = re.search(r"Tab le 96.*?%s.*?\n.*? \d(.*?)\n.*?" %char , neuro, re.S )
if match:
VAR = match.group(1). split()[1]
else:
VAR = 0
if VAR=="-": VAR = 0
VAR = even_odd_round( float(str(VAR)) )
VAR = float(str(VAR))/100
sh.Cells(i+8,la stcol+1).Value = VAR
sh.Cells(10,las tcol+1).Value= sh.Cells(9,last col+1).Value
sh.Cells(9,last col+1).Value = sh.Cells(8,last col+1).Value - sh.Cells(10,las tcol+1).Value
VAR=[]
BASE = re.search("Tabl e 97.*?BASE.*?\d( .*?)\n", neuro, re.S ).group(1).spli t()[1]
sh.Cells(11,las tcol+1).Value = BASE
for i, char in enumerate(["RECEIVED E", "PARTICIPAT ED "]):
match = re.search(r"Tab le 97.*?%s.*?\n.*? \d(.*?)\n.*?" %char , neuro, re.S )
if match:
VAR = match.group(1). split()[1]
else:
VAR = 0
if VAR=="-": VAR = 0
VAR = even_odd_round( float(str(VAR)) )
VAR = float(str(VAR))/100
sh.Cells(i+12,l astcol+1).Value = VAR
sh.Cells(14,las tcol+1).Value= sh.Cells(13,las tcol+1).Value
sh.Cells(13,las tcol+1).Value = sh.Cells(12,las tcol+1).Value - sh.Cells(14,las tcol+1).Value
How do I add another index inside a re.search?
I want to add
for j in [96,97,98,99]
BASE = re.search ...
sh.Cells97...
for i ....
so that the Table 96 within the re.search(s) becomes Table 96, Table 97, Table 98, Table 99
but don't know how to add a second index within the re.search since I already have %char
in match = re.search ... " %char, neuro ...
VAR=[]
BASE = re.search("Tabl e 96.*?BASE.*?\d( .*?)\n", neuro, re.S ).group(1).spli t()[1]
sh.Cells(7,last col+1).Value = BASE
for i, char in enumerate(["RECEIVED E", "PARTICIPAT ED "]):
match = re.search(r"Tab le 96.*?%s.*?\n.*? \d(.*?)\n.*?" %char , neuro, re.S )
if match:
VAR = match.group(1). split()[1]
else:
VAR = 0
if VAR=="-": VAR = 0
VAR = even_odd_round( float(str(VAR)) )
VAR = float(str(VAR))/100
sh.Cells(i+8,la stcol+1).Value = VAR
sh.Cells(10,las tcol+1).Value= sh.Cells(9,last col+1).Value
sh.Cells(9,last col+1).Value = sh.Cells(8,last col+1).Value - sh.Cells(10,las tcol+1).Value
VAR=[]
BASE = re.search("Tabl e 97.*?BASE.*?\d( .*?)\n", neuro, re.S ).group(1).spli t()[1]
sh.Cells(11,las tcol+1).Value = BASE
for i, char in enumerate(["RECEIVED E", "PARTICIPAT ED "]):
match = re.search(r"Tab le 97.*?%s.*?\n.*? \d(.*?)\n.*?" %char , neuro, re.S )
if match:
VAR = match.group(1). split()[1]
else:
VAR = 0
if VAR=="-": VAR = 0
VAR = even_odd_round( float(str(VAR)) )
VAR = float(str(VAR))/100
sh.Cells(i+12,l astcol+1).Value = VAR
sh.Cells(14,las tcol+1).Value= sh.Cells(13,las tcol+1).Value
sh.Cells(13,las tcol+1).Value = sh.Cells(12,las tcol+1).Value - sh.Cells(14,las tcol+1).Value
Comment