On Nov 17, 3:24 am, Lawrence D'Oliveiro <[EMAIL PROTECTED]
central.gen.new_zealand> wrote:
> len wrote:
> > Files are fixed format no field delimiters, fields are position and
> > length records are terminated by newline.
>
> Assuming no COMPUTATIONAL fields, it should be easy enough to split each line 
> up into fixed-length pieces, e.g. assuming a simple example
>
>     01 Sample-Record.
>       02 Field-1 pic XXX.
>       02 Field-2 pic XXXX.
>       02 Field-3 pic XXXXX.
>
> then a Python sequence that read one line's worth of fields might be
>
>     line = infile.read()
>     (field_1, field_2, field_3) = (line[0:3], line[3:7], line[7:12])

Thank you for the suggestion.  I have done what you have suggested and
if your interested you can take a look at the code in my post titled;

'Newbie code review of parsing program Please'

Just shows great minds run in the same gutter;)

Len
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to