How can I use python for file processing

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sun Aug 26 08:50:43 CEST 2007


On Sun, 26 Aug 2007 06:05:11 +0000, yinglcs at gmail.com wrote:

> I am trying to use python for file processing.
> Suppose I have a file like this:
> I want to build a Hashmap between the line "begin_QOS_statistics" and
> "end_QOS_statistics"
> and for each line I want to put the first text as the key of the hash
> table and the second text as the value.

Work through the tutorial, experiment a little in the interactive
interpreter and then just do it.  You need to `open()` the file, iterate
over its lines in a ``for``-loop, decide to when it is time to start
processing lines, and then `str.split()` the lines and put them into a
`dict()`.  This is a neat little project to start learning the language.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list