[Tutor] Field/Variable References
Dave Angel
davea at ieee.org
Sat Dec 19 03:35:00 CET 2009
John Filben wrote:
> Can someone please let me know how to read a file one record at a time (just say fixed block for now - see small example below) and assign columns to fields. Then reference the field names with if-then-else logic.
>
> Sample Fixed Block File:
>
> John98762
> John82634
> John11234
>
> Thank you.
> John Filben
> Cell Phone - 773.401.2822
> Email - johnfilben at yahoo.com
>
>
>
The other responses all seem to assume that you have linefeeds between
records. But you said it was fixed-block, which implies no linefeeds.
Anyway, to fetch those blocks, use the file.read() method, where you
can give the fixed size. You can separate the blocks with slicing, or
you can do something trickier.
DaveA
More information about the Tutor
mailing list