extract to dictionaries

Marius Retegan marius.s.retegan at gmail.com
Fri May 29 06:44:30 EDT 2009


Hi,

On Fri, May 29, 2009 at 2:09 AM, Gary Herron <gherron at islandtraining.com>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
>> end
>>
>> So I want to create two dictionaries parameters1={key1:value1,
>> key2:value2} and the same for parameters2.
>>
>> I would appreciate any help that could help me solve this.
>> Thank you
>>
>>
>
> This looks like a homework problem.


It's not. I'm passed homework age.


>   But even if it's not, you are not likely to find someone who is willing
> to put more work into this problem than you have.
> So  why don't you show us what you've tried, and see if someone is willing
> to make suggestions or answer specific question about your attempt at a
> solution?
>

I don't now if posting a code that gets into a while loop and never stops
would demonstrate to you that I've tried. Be assured that before posting to
the list I did try to solve it myself, because I knew that I might get an
answer like RTFM or similar.
Maybe I'm not smart enough, but I can't make python to start reading after
the "parameter1" line and stop at the "end" line. That's all I want a small
piece of pseudocode to do just that.

Thanks


>
> Gary Herron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090529/0791a9b1/attachment-0001.html>


More information about the Python-list mailing list