Parsing of a file

Tommy Grav tgrav at
Fri Aug 8 03:13:19 CEST 2008

On Aug 7, 2008, at 12:52 PM, Mike Driscoll wrote:
> I'm well aware of the split() method and built-ins, however since this
> appeared to be a homework-type question and I was at work, I didn't
> spend any time on the issue. The only reason I mentioned McGuire's
> PyParsing module was because I had just finished reading his article
> on the subject in Python Magazine and it sounded like something the OP
> might find interesting.\

Thanks to everyone that responded, I learned a lot about text parsing  
the responses. I just wanted to respond to Mike and let him know that  
was not a homework problem. I was given a file in the format by a  
for a project that I am working on (it contains a list of fields  
observed by
the LINEAR asteroid search project during 2005 and 2006). I could have
parsed it using slices of each line, but the unusual format of each line
got me thinking about wether there was another way to do it. I had  
tried a
few approaches, but I had not considered the .split() and .split("=").  
Of course
the list members quickly came up with a simple and elegant solution. And
I learned a lot in the process :)

Tommy Grav
   Associate Research Scientist			Dept. of Physics and Astronomy
   Johns Hopkins University			Bloomberg 243
   tgrav at					3400 N. Charles St.
   (410) 516-7683					Baltimore, MD21218

More information about the Python-list mailing list