Split file into several and reformat

Neil Cerutti horpner at yahoo.com
Thu Jun 21 08:44:01 EDT 2007


On 2007-06-21, bomber71 at aapt.net.au <bomber71 at aapt.net.au> wrote:
> Hi,
>
> I want to take read an input file (sels.txt) that looks like:
>
> Begin sels
>    sel1 = {1001, 1002, 1003, ...
>            ...
>            1099}
>
>    sel2 = {1001, 1008, 1009 ...
>            ...
>            1299}
> End sels
>
> And turn it into an output file for each of the "sels" in the input file, i.e
> sel1.txt:
>
> L1001
> L1002
> L1003
> ...
> L1099
>
> and sel2.txt:
>
> L1001
> L1008
> L1009
> ...
> L1299
>
> And so on. Many thanks,

I think I'd put together a simple grammar and then write a
recursive descent parser that spit out my output files. But
that's just because I find that kind of thing fun. ;)

-- 
Neil Cerutti
I'm tired of hearing about money, money, money, money, money. I just want to
play the game, drink Pepsi, wear Reebok. --Shaquille O'Neal



More information about the Python-list mailing list