convert non-delimited to delimited

Neil Cerutti horpner at yahoo.com
Mon Aug 27 14:44:18 EDT 2007


On 2007-08-27, RyanL <ryanlauritsen at gmail.com> wrote:
> I'm a newbie!  I have a non-delimited data file that I'd like to
> convert to delimited.
>
> Example...
> Line in non-delimited file:
> 0139725635999992000010100534+42050-102800FM-15+1198KAIA
>
> Should be:
> 0139,725635,99999,2000,01,01,00,53,4,+42050,-102800,FM-15,+1198,KAIA

It looks like a fixed format data file, also called flat-record
files, in which fields are of fixed lengths, and records are
separated by newlines.

> What is the best way to go about this?  

Check out chapter 2 of _Text Processing in Python_ for one
solution.

http://gnosis.cx/TPiP/chap2.txt

-- 
Neil Cerutti
Weight Watchers will meet at 7 p.m. Please use large double door at the side
entrance. --Church Bulletin Blooper



More information about the Python-list mailing list