"Kemp Randy-W18971" <Randy.L.Kemp at motorola.com> wrote in message news:mailman.986219102.21440.python-list at python.org... > It's been a while since I worked with Python, so tell me how to do this. > > I have a text file, and for simplicity sake, I will only put in two entries > > Min. line width (mils): 4 > 4.00 mils trace segment count / % of total: 5598/80.10 % > > I wish to parse this input file and just output the numbers in a separate text file, like so > 4 > 5598 > 80.10 > > I think I will need the split function, but what is the simplest way to accomplish this? Depending on how you want to define "the numbers", something like: import re number = re.compile(r'\d+\.?\d*') rawtext = open('a.txt').read() for anumber in number.findall(rawtext): print anumber might come close to working, however, if a.txt is your example file, the output would be: D:\>python genus.py 4 4.00 5598 80.10 as there is no indication that, out of the four 'numbers' it finds, it needs to ignore the "4.00" one. So, if you only want three 'numbers' from that example, you need to refine your specs... Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4