Re: [BangPypers] How should I do it?

2010-01-15 Thread Dhananjay Nene
On Fri, Jan 15, 2010 at 12:01 PM, Eknath Venkataramani < eknath.i...@gmail.com> wrote: > I have a txt file in the following format: > [code] > "confident" => { > count => 4, > trans => { > "ashahvasahta" => 0.74918568, >"atahmavaishahvaasa" => 0.09095465, >"pahraaram\.nbha" => 0.0699

Re: [BangPypers] How should I do it?

2010-01-15 Thread Noufal Ibrahim
On Fri, Jan 15, 2010 at 4:13 PM, Anand Chitipothu wrote: > On Fri, Jan 15, 2010 at 4:00 PM, Baishampayan Ghose > wrote: > >> It is a clever hack, taking advantage of the nature of the data. But > >> it is far more faster than the other approaches posted here. > > > > I thought eval was evil :) >

Re: [BangPypers] How should I do it?

2010-01-15 Thread Anand Balachandran Pillai
On Fri, Jan 15, 2010 at 4:13 PM, Anand Chitipothu wrote: > On Fri, Jan 15, 2010 at 4:00 PM, Baishampayan Ghose > wrote: > >> It is a clever hack, taking advantage of the nature of the data. But > >> it is far more faster than the other approaches posted here. > > > > I thought eval was evil :) >

Re: [BangPypers] How should I do it?

2010-01-15 Thread Anand Chitipothu
On Fri, Jan 15, 2010 at 4:00 PM, Baishampayan Ghose wrote: >> It is a clever hack, taking advantage of the nature of the data. But >> it is far more faster than the other approaches posted here. > > I thought eval was evil :) The date looks like valid json. You can use simplejson.loads instead of

Re: [BangPypers] How should I do it?

2010-01-15 Thread Anand Balachandran Pillai
On Fri, Jan 15, 2010 at 4:03 PM, Noufal Ibrahim wrote: > On Fri, Jan 15, 2010 at 4:00 PM, Baishampayan Ghose >wrote: > > > > It is a clever hack, taking advantage of the nature of the data. But > > > it is far more faster than the other approaches posted here. > > > > I thought eval was evil :)

Re: [BangPypers] How should I do it?

2010-01-15 Thread Noufal Ibrahim
On Fri, Jan 15, 2010 at 4:00 PM, Baishampayan Ghose wrote: > > It is a clever hack, taking advantage of the nature of the data. But > > it is far more faster than the other approaches posted here. > > I thought eval was evil :) > Given that the OPs data is fixed, eval is okay. :) Otherwise, it c

Re: [BangPypers] How should I do it?

2010-01-15 Thread Baishampayan Ghose
> It is a clever hack, taking advantage of the nature of the data. But > it is far more faster than the other approaches posted here. I thought eval was evil :) Regards, BG -- Baishampayan Ghose b.ghose at gmail.com ___ BangPypers mailing list BangPyp

Re: [BangPypers] How should I do it?

2010-01-15 Thread Roshan Mathews
On Fri, Jan 15, 2010 at 2:40 PM, Anand Balachandran Pillai wrote: >    # Now, count and trans are not strings in >    # data, so Python will complain, hence we >    # define these as strings with same name! >    count, trans = 'count','trans' > Clever, that. I got to there, threw up my hands and

Re: [BangPypers] How should I do it?

2010-01-15 Thread Kenneth Gonsalves
On Friday 15 Jan 2010 12:01:56 pm Eknath Venkataramani wrote: > and I need to extract "confident" , "ashahvasahta" from the first > record, "consumers", "upabhaokahtaa" from the second record... > i.e. "word in english" and the "first word in the probable-translations" > #!/usr/bin/python words

Re: [BangPypers] How should I do it?

2010-01-15 Thread Anand Balachandran Pillai
On Fri, Jan 15, 2010 at 2:17 PM, Noufal Ibrahim wrote: > On Fri, Jan 15, 2010 at 1:04 PM, Dhananjay Nene >wrote: > > > This seems to be an output of print_r of PHP. If you have a flexibility, > > try > > to have the PHP code output the data into a language neutral format (eg > > json, yaml, xml

Re: [BangPypers] How should I do it?

2010-01-15 Thread Noufal Ibrahim
On Fri, Jan 15, 2010 at 1:04 PM, Dhananjay Nene wrote: > This seems to be an output of print_r of PHP. If you have a flexibility, > try > to have the PHP code output the data into a language neutral format (eg > json, yaml, xml etc.) and then parse it in python using the appropriate > parser. If n

Re: [BangPypers] How should I do it?

2010-01-14 Thread Dhananjay Nene
This seems to be an output of print_r of PHP. If you have a flexibility, try to have the PHP code output the data into a language neutral format (eg json, yaml, xml etc.) and then parse it in python using the appropriate parser. If not you may have to write a custom parser. I did google to find if

[BangPypers] How should I do it?

2010-01-14 Thread Eknath Venkataramani
I have a txt file in the following format: [code] "confident" => { count => 4, trans => { "ashahvasahta" => 0.74918568, "atahmavaishahvaasa" => 0.09095465, "pahraaram\.nbha" => 0.06990729, "mailatae" => 0.02856427, "utanai" => 0.01929341, "anaa" =>