[BangPypers] How should I do it?
Dhananjay Nene
dhananjay.nene at gmail.com
Fri Jan 15 08:34:13 CET 2010
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 one existed, but couldn't easily locate one.
Dhananjay
On Fri, Jan 15, 2010 at 12:01 PM, Eknath Venkataramani <
eknath.iyer at 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.06990729,
> "mailatae" => 0.02856427,
> "utanai" => 0.01929341,
> "anaa" => 0.01578552,
> "uthaanae" => 0.01403157,
> "jaitanae" => 0.01227762,
> },
> },
> "consumers" => {
> count => 4,
> trans => {
> "upabhaokahtaa" => 0.75144362,
> "upabhaokahtaaom\.n" => 0.12980166,
> "sauda\�\�\�dha" => 0.11875471,
> },
> },
> "a" => {
> count => 1164,
> trans => {
> "eka" => 0.14900491,
> "kaisai" => 0.08834675,
> "haai" => 0.06774697,
> "kaoi" => 0.05394308,
> "kai" => 0.04981982,
> "\(none\)" => 0.04400085,
> "kaa" => 0.03726579,
> "kae" => 0.03446450,
> },
> },
> [/code]
>
> 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"
>
> Thanks is advance
> Eknath
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
--
--------------------------------------------------------
blog: http://blog.dhananjaynene.com
twitter: http://twitter.com/dnene http://twitter.com/_pythonic
More information about the BangPypers
mailing list