[Tutor] Please help
alan.gauld at freenet.co.uk
Wed Aug 3 19:01:00 CEST 2005
> sorry for repost.
OK, since nobody respoinded I'll make a few suggestions.
> I have a file (3339203 lines) that looks like this:
Get it working first then worry about tuning it for the volumes later.
> (col:1) (col:2) (col:3)
Is the above explanatory or part of the file?
Doesn't matter juch but just to be clear.
> XXXXX XXXXX
> Xaaaa Xaaaa
> Xbbbb Xbbbb
> AD134KL XXXXX XXXXX
> AD134KL Xaaaa Xaaaa
> AD134KL Xbbbb Xbbbb
So when you find a line with one field you need to store that
value and preppend it to all subsequent lines until you get
an empty line or another with a single field?
In pseudo code:
for line in infile
if len(line) == 1: # just a newline
fields = line.strip().split()
if len(fields) == 1
tag = fields
output = line
output = "%12s%12s%12s\n" % tuple(fields)
Does that make any kind of sense?
More information about the Tutor