Re: Stripping non-numbers from a file parse without nested lists?

2009-04-01 Thread daku9999
On Mar 31, 6:47 pm, Rhodri James rho...@wildebst.demon.co.uk wrote: What you're doing (pace error checking) seems fine for the data structures that you're using.  I'm not entirely clear what your usage pattern for dip and dir is once you've got them, so I can't say whether there's a more

Re: Stripping non-numbers from a file parse without nested lists?

2009-04-01 Thread Lorenzo
Maybe you can try a regex, something like -- import re pattern = re.compile('^(\d+)/(\d+).*') def read_data(filename): fh = open(filename, r, encoding=ascii) for line in fh: if pattern.match(line): dip_,dir_ = pattern.match(line).groups()

Re: Stripping non-numbers from a file parse without nested lists?

2009-04-01 Thread jay logan
On Apr 1, 2:35 am, daku9...@gmail.com wrote: On Mar 31, 6:47 pm, Rhodri James rho...@wildebst.demon.co.uk wrote: What you're doing (pace error checking) seems fine for the data structures that you're using.  I'm not entirely clear what your usage pattern for dip and dir is once you've got

Re: Stripping non-numbers from a file parse without nested lists?

2009-04-01 Thread jay logan
On Apr 1, 11:05 am, jay logan dear.jay.lo...@gmail.com wrote: On Apr 1, 2:35 am, daku9...@gmail.com wrote: On Mar 31, 6:47 pm, Rhodri James rho...@wildebst.demon.co.uk wrote: What you're doing (pace error checking) seems fine for the data structures that you're using.  I'm not

Re: Stripping non-numbers from a file parse without nested lists?

2009-04-01 Thread daku9999
On Apr 1, 8:10 am, jay logan dear.jay.lo...@gmail.com wrote: On Apr 1, 11:05 am, jay logan dear.jay.lo...@gmail.com wrote: On Apr 1, 2:35 am, daku9...@gmail.com wrote: On Mar 31, 6:47 pm, Rhodri James rho...@wildebst.demon.co.uk wrote: What you're doing (pace error checking)

Re: Stripping non-numbers from a file parse without nested lists?

2009-03-31 Thread andrew cooke
Rhodri James wrote: On Tue, 31 Mar 2009 06:51:33 +0100, daku9...@gmail.com wrote: There has got to be a better way of doing this: I'm reading in a file that has a lot of garbage, but eventually has something that looks similar to: (some lines of garbage) dip/dir. (some more lines of

Re: Stripping non-numbers from a file parse without nested lists?

2009-03-31 Thread Rhodri James
On Tue, 31 Mar 2009 06:51:33 +0100, daku9...@gmail.com wrote: There has got to be a better way of doing this: I'm reading in a file that has a lot of garbage, but eventually has something that looks similar to: (some lines of garbage) dip/dir. (some more lines of garbage) 55/158 (some more

Stripping non-numbers from a file parse without nested lists?

2009-03-30 Thread daku9999
There has got to be a better way of doing this: I'm reading in a file that has a lot of garbage, but eventually has something that looks similar to: (some lines of garbage) dip/dir. (some more lines of garbage) 55/158 (some more lines of garbage) 33/156 etc. and I'm stripping out the 55/158