473,397 Members | 1,950 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,397 software developers and data experts.

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 1113
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: bugbear | last post by:
Subject pretty much says it all. I'd like to parse XML (duh!) using Xerces (because its fast, and reliable, and comprehensive, and supports lots of features). I'd like to conform to standards...
8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
4
by: Josef Wolf | last post by:
Hello! Is it possible to have CVS-style command line options with the optparse module? I could get as far as: import sys from optparse import OptionParser, OptionGroup parser =...
1
by: F. GEIGER | last post by:
I'm rather new to high level parsing with lex/yacc (and realy impressed so far). I'd like to parse *and execute* files like this: A=12 B=23 G X=A Y=B Z=34 # Move to X, Y, Z G Z=0
1
by: Scott | last post by:
I am new to perl, and have not found any good examples of parsing to help me out. I have a text file that I am reading into an array that has to be parsed out and put into another file. I have not...
1
by: Christoph Bisping | last post by:
Hello! Maybe someone is able to give me a little hint on this: I've written a vb.net app which is mainly an interpreter for specialized CAD/CAM files. These files mainly contain simple movement...
1
by: Przemyslaw Wegrzyn | last post by:
Hi ! Can anyone here recommend good e-mail parsing library ? I have to write a program that scans e-mail message piped to it on STDIN. Most libraries I've found parses e-mail from file building...
2
by: Andy | last post by:
Hi guys, I'm writing a program with a feature of accepting user input as command text and parsing it to correct function calls...example: "5 minutes later"/"5 min later"/"5 minute...
12
by: Klaus Alexander Seistrup | last post by:
Hi group, I am new to xgawk (and seemingly to xml also), and I've been struggling all afternoon to have xgawką parsing an XHTML file containing a hCard˛, without luck. I wonder if you guys...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
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
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...

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.