473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

help with looping, re.search, multiple indexing

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("Table 96.*?BASE.*?\d(.*?)\n", neuro, re.S ).group(1).split()[1]
sh.Cells(7,lastcol+1).Value = BASE

for i, char in enumerate(["RECEIVED E", "PARTICIPATED "]):
match = re.search(r"Table 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,lastcol+1).Value = VAR
sh.Cells(10,lastcol+1).Value= sh.Cells(9,lastcol+1).Value
sh.Cells(9,lastcol+1).Value = sh.Cells(8,lastcol+1).Value - sh.Cells(10,lastcol+1).Value

VAR=[]
BASE = re.search("Table 97.*?BASE.*?\d(.*?)\n", neuro, re.S ).group(1).split()[1]
sh.Cells(11,lastcol+1).Value = BASE
for i, char in enumerate(["RECEIVED E", "PARTICIPATED "]):
match = re.search(r"Table 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,lastcol+1).Value = VAR

sh.Cells(14,lastcol+1).Value= sh.Cells(13,lastcol+1).Value
sh.Cells(13,lastcol+1).Value = sh.Cells(12,lastcol+1).Value - sh.Cells(14,lastcol+1).Value

Feb 16 '07 #1
1 1230
Lance Hoffmeyer wrote:
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 ...
You can make format strings with an arbitrary number of values by providing
a tuple

r"Table %d.*?%s.*?\n.*?\d(.*?)\n.*?" % (j, char)

or a dict

r"Table %(table)d.*?%(char)s.*?\n.*?\d(.*?)\n.*?" % dict(table=j, char=char)

on the right side of the % operator.

http://docs.python.org/lib/typesseq-strings.html

Peter
Feb 16 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

83
by: D. Dante Lorenso | last post by:
Trying to use the 'search' in the docs section of PostgreSQL.org is extremely SLOW. Considering this is a website for a database and databases are supposed to be good for indexing content, I'd...
3
by: RiceGuy | last post by:
Hi! I'm looking for ideas on what would the best approach to design a search system for a RSS feeds. I will have some 50 RSS feeds (all RSS 2.0 compliant) stored locally on the web server. Now I'm...
4
by: kreepssss | last post by:
HI all: i hope that every body is just well fine 'cause i need a little help around: well i m trying (it's my first try) to work on the MS.Office Access.... i have build all the tables and the...
0
by: Chung Leong | last post by:
Here's a short tutorial on how to the OLE-DB extension to access Windows Indexing Service. Impress your office-mates with a powerful full-text search feature on your intranet. It's easier than you...
3
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: iskyline | last post by:
hi there, i'm very new to programming with databases ... i'm coding in vbscripting because i'm trying to make a user friendly HTA for the people at work. so the basic process... search...
1
by: vikjohn | last post by:
I have a new perl script sent to me which is a revision of the one I am currently running. The permissions are the same on each, the paths are correct but I am getting the infamous : The specified...
8
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.