Little direction please Python MySQL

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Mon Nov 17 04:24:10 EST 2008


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])



More information about the Python-list mailing list