470,599 Members | 1,445 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,599 developers. It's quick & easy.

Parsing Hints

mwt
Hi -
I'm working on parsing a file that has data that looks like the sample
below. Obviously, I can't just split the string by colons. I'm pretty
new to regex, but I was thinking of something that would essentially
"split" by colons only if the are preceded by alpha characters -- thus
eliminating problems of splitting up times, etc. Still, I'm nagged by
the spectre of you gurus knowing a powerful way to approach this
problem. Am I on the right track here with this regex idea? Any hints
as to the sanest angle on parsing this would be appreciated. Thanks.

Here's a sample of the data:

Index 4: folding now
server: 171.65.199.158:8080; project: 1809
Folding: run 17, clone 19, generation 35; benchmark 669; misc: 500,
400
issue: Wed Mar 15 18:32:19 2006; begin: Wed Mar 15 18:32:25 2006
due: Fri Apr 28 19:32:25 2006 (44 days)
core URL: http://www.stanford.edu/~pande/Linux/x86/Core_82.fah
CPU: 1,0 x86; OS: 4,0 Linux
assignment info (le): Wed Mar 15 18:32:19 2006; A0F3AAD2
CS: 171.65.103.100; P limit: 5241856
user: MWT; team: 0; ID: 1A2BFB777775B7B; mach ID: 2
work/wudata_04.dat file size: 82814; WU type: Folding@Home
Average download rate 97.552 KB/s (u=4); upload rate 38.718 KB/s (u=3)
Performance fraction 0.950453 (u=3)

Mar 17 '06 #1
2 1049
mwt
OK. I think the solution was much easier than I thought. The key is the
semicolon. I'm doing it in 3 steps:
1) Break string into 13 lines
2) Split each line by the semi-colon
3) Ummm... done already.

Time to wake up. ;)

Mar 17 '06 #2
mwt wrote:
Hi -
I'm working on parsing a file that has data that looks like the sample
below.

Here's a sample of the data:

Index 4: folding now
server: 171.65.199.158:8080; project: 1809
Folding: run 17, clone 19, generation 35; benchmark 669; misc: 500,
400
issue: Wed Mar 15 18:32:19 2006; begin: Wed Mar 15 18:32:25 2006
due: Fri Apr 28 19:32:25 2006 (44 days)
core URL: http://www.stanford.edu/~pande/Linux/x86/Core_82.fah
CPU: 1,0 x86; OS: 4,0 Linux
assignment info (le): Wed Mar 15 18:32:19 2006; A0F3AAD2
CS: 171.65.103.100; P limit: 5241856
user: MWT; team: 0; ID: 1A2BFB777775B7B; mach ID: 2
work/wudata_04.dat file size: 82814; WU type: Folding@Home
Average download rate 97.552 KB/s (u=4); upload rate 38.718 KB/s (u=3)
Performance fraction 0.950453 (u=3)


You don't say what data you are trying to extract. If it is key:value
pairs where the key is everything before the first colon, just use
line.split(':', 1) to split on just the first colon.

Kent
Mar 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Gerrit Holl | last post: by
4 posts views Thread by Josef Wolf | last post: by
1 post views Thread by F. GEIGER | last post: by
1 post views Thread by Scott | last post: by
1 post views Thread by Christoph Bisping | last post: by
1 post views Thread by Przemyslaw Wegrzyn | last post: by
12 posts views Thread by Klaus Alexander Seistrup | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.