473,569 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("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

Feb 16 '07 #1
1 1238
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.*?%(c har)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
5869
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 expect a much faster performance. I submitted my search over two minutes ago. I just finished this email to the list. The results have still not...
3
654
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 wondering what would the best method to allow searching of these RSS files. Since the search will cater to multiple users the search system has to...
4
1143
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 form and every thing i need but i need to know if i can make a form that allow me to search all the data that i have entred in the data base .... i...
0
4208
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 think. First, download and install the extension (http://sourceforge.net/project/showfiles.php?group_id=171247&package_id=198554). Simply unzip...
3
9539
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 MusicAlbum let you find MP3 and other music files based on the singer and album name; DocAuthor let you find Office documents created by a certain user;...
0
5542
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 ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
1
1590
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 recursively for txt files in a given folder - works fine import first text file into a database table1 -works fine --------i'm having a problem...
1
2924
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 CGI application misbehaved by not returning a complete set of HTTP headers. The scripts are very long but here are the opening statements: The One...
8
5088
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 indexed). dbo.maintable(ProfileID int pk) dbo.fts_table(ProfileID int pk fk, col1 xml, col2 xml, col3 xml) I want to perform a query that will return...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.