Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81973

Re: help with processing text file

Date 2014-12-04 20:54 -0800
From Gary Herron <gary.herron@islandtraining.com>
Subject Re: help with processing text file
References <d3e302d4-f4de-4307-8c72-60ed643b264d@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.16605.1417755628.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 12/04/2014 08:46 PM, C. Ng wrote:
> Hi,
>
> Given the sample text file below (where the gibberish represent the irrelevant portions) :
>
> ....
> abcddsdfffgfg
> ggfhghghgfhghgh   round 5 xccdcxcfd
> sdfdffdfbcvcvbbvnghg score = 0.4533
> abcddsdfffgfg     round 5 level = 0.15
> ggfhghghgfhghgh   round 10 dfsdfdcdsd
> sdfdffdfbcvcvbbvnghg score = 0.4213
> sdsdaawddddsds    round 10 level = 0.13
> ......and so on....
>
>
> I would like to extract the values for round, score and level:
> 5 0.4533 0.15
> 10 0.4213 0.13
> ....and so on...
>
> Please advise me how it can be done, and what Python functions are useful.
>
> Thanks.

I would use regular expressions.  See 
https://docs.python.org/3/library/re.html

Gary Herron

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

help with processing text file "C. Ng" <ngcbmy@gmail.com> - 2014-12-04 20:46 -0800
  Re: help with processing text file Gary Herron <gary.herron@islandtraining.com> - 2014-12-04 20:54 -0800
  Re: help with processing text file Dave Angel <davea@davea.name> - 2014-12-05 00:46 -0500

csiph-web