Re: extract to dictionaries

2009-05-29 Thread Mike Kazantsev
On Thu, 28 May 2009 16:03:45 -0700 (PDT) Marius Retegan wrote: > Hello > I have simple text file that I have to parse. It looks something like > this: > > parameters1 > key1 value1 > key2 value2 > end > > parameters2 > key1 value1 > key2 value2 > end > > So I want to create

Re: extract to dictionaries

2009-05-29 Thread Emile van Sebille
On 5/28/2009 4:03 PM Marius Retegan said... Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1 value1 key2 value2 end parameters2 key1 value1 key2 value2 end So I want to create two dictionaries parameters1={key1:value1, key2:

Re: extract to dictionaries

2009-05-29 Thread Gary Herron
Marius Retegan wrote: Hi, On Fri, May 29, 2009 at 2:09 AM, Gary Herron mailto:gher...@islandtraining.com>> wrote: Marius Retegan wrote: Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1

Re: extract to dictionaries

2009-05-29 Thread Rhodri James
On Fri, 29 May 2009 13:10:47 +0100, Rhodri James wrote: current_name = dummy Gah! I meant, of course, current_name = 'dummy' -- Rhodri James *-* Wildebeeste Herder to the Masses -- http://mail.python.org/mailman/listinfo/python-list

Re: extract to dictionaries

2009-05-29 Thread Rhodri James
On Fri, 29 May 2009 11:44:30 +0100, Marius Retegan wrote: Hi, On Fri, May 29, 2009 at 2:09 AM, Gary Herron wrote: Marius Retegan wrote: Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1 value1 key2 value2 end parameters2 k

Re: extract to dictionaries

2009-05-29 Thread Marius Retegan
Hi, On Fri, May 29, 2009 at 2:09 AM, Gary Herron wrote: > Marius Retegan wrote: > >> Hello >> I have simple text file that I have to parse. It looks something like >> this: >> >> parameters1 >> key1 value1 >> key2 value2 >> end >> >> parameters2 >> key1 value1 >> key2 value2 >> en

Re: extract to dictionaries

2009-05-28 Thread Teguh Iskanto
You can create this modularly by : 1. parse the file and cut this into different chunks ( look for 'end' ) then you have two chunks for param 1 & 2 2. once you have those chunks then process each chunk with your own processing based on your parameters ( 1 or 2 ) 3. then based on your individual par

Re: extract to dictionaries

2009-05-28 Thread Gary Herron
Marius Retegan wrote: Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1 value1 key2 value2 end parameters2 key1 value1 key2 value2 end So I want to create two dictionaries parameters1={key1:value1, key2:value2} and the same f

Re: extract to dictionaries

2009-05-28 Thread bearophileHUGS
Marius Retegan: > > parameters1 >      key1 value1 >      key2 value2 > end > > parameters2 >      key1 value1 >      key2 value2 > end > > So I want to create two dictionaries parameters1={key1:value1, > key2:value2} and the same for parameters2. I have wasted some time trying to create a regex f

extract to dictionaries

2009-05-28 Thread Marius Retegan
Hello I have simple text file that I have to parse. It looks something like this: parameters1 key1 value1 key2 value2 end parameters2 key1 value1 key2 value2 end So I want to create two dictionaries parameters1={key1:value1, key2:value2} and the same for parameters2. I woud