Working with fixed format text db's

Lloyd Zusman ljz at asfast.com
Sat Jun 9 07:18:43 EDT 2007


Frank Millman <frank at chagford.com> writes:

> On Jun 8, 5:50 pm, Neil Cerutti <horp... at yahoo.com> wrote:
>> Many of the file formats I have to work with are so-called
>> fixed-format records, where every line in the file is a record,
>> and every field in a record takes up a specific amount of space.
>>
>> [ ... ]
>
> We already have '%-12s' to space fill for a length of 12, but it is
> not truly fixed-length, as if the value has a length greater than 12
> you need it to be truncated, and this construction will not do that.

In this case, we can use '%-12.12s'.

-- 
 Lloyd Zusman
 ljz at asfast.com
 God bless you.




More information about the Python-list mailing list