[Tutor] files - strings - lists

Andrzej Kolinski AKolinski at nriindustries.com
Wed Nov 23 16:14:24 CET 2005


I want to create a program that uses data from text files, makes 
appropriate calculations and produces report. First I need to find out 
what is the right way to retrieve appropriate information from an input 
file. This is a typical format of the input file:

1 Polonijna Liga Mistrzow       |from the heading portion
26 wrzesnia 2005                        |only
 6 12 6 4 1                             |'6' and '4' will be needed
 0 1 0
Bohossian - Kolinski            |all names and 
1                                       |all scores
      1.000 9 13 19             |(3rd column -
      2.000 2 4 16              |'13', '4', '8', '6'
      1.000 10 8 17             |will be needed
      0.000 8 6 17              |
Szadkowska - Szczurek           |
2                                       |same here
      0.000 11 16 20            |
      3.000 1 -4 14             |
      3.500 3 -7 13
      2.500 10 13 19 
..................

 1 1                                    |skip the rest
 1 1 1                          |(at least for now)
 6 4
 5 10
 8 3
 9 1
 11 2
 12 7
 -50 -7 7
 0 0 0
 400 0 0
 -110 -2 2
 -130 1 -1
 100 -1 1
 110 -4 4
 150 4 -4
 400 0 0
 -90 -1 1
 100 6 -6
 100 -1 1
 420 4 -4
 110 5 -5
 -480 -1 1
 1310 15 -15
............

Should I use string manipulations or convert a file to lists of lists to 
retrieve names and numbers? I have unsuccessfully tried to code using the 
latter but I couldn't overcome the fact that lists representing each raw 
of a text file have different lengths.

How could I associate each name with a score (a sum of scores)?

 
        _/_/      _/     _/
   _/       _/  _/   _/
  _/_/_/_/  _/ _/
 _/      _/  _/   _/
_/     _/  _/      _/

Andrzej Kolinski
office 416.652.4256
cell.  416.948.7767
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051123/e4dc2c5c/attachment.html


More information about the Tutor mailing list