help with processing text file

Gary Herron gary.herron at islandtraining.com
Thu Dec 4 23:54:15 EST 2014


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



More information about the Python-list mailing list