On 01/12/2016 06:21 PM, Angel Herráez wrote:
> Hi all
>
> I am trying to parse some data that is, as far as I can guess, in JSON format
> Data is at http://www.ebi.ac.uk/pdbe/api/pdb/entry/molecules/2k8v
>
> I am trying to do
>   f = load("http://www.ebi.ac.uk/pdbe/api/pdb/entry/molecules/2k8v";)
>
> and "print f" shows it
>
> {"2k8v":[{
>       "entity_id":1,
>       "weight":17801.109,
> etc
>
> Now the question: how to extract parts of the data, like the value for the
> "weight" key?
Angel, you need an 'eval' around the 'load' command:

f = eval(load("http://www.ebi.ac.uk/pdbe/api/pdb/entry/molecules/2k8v";))

Then you have full access to the data structure, e.g.:

show f;
print f["2k8v"]..[1];
print f..2k8v..[1];
print f..2k8v..[1].keys;
print f..2k8v..[1]..sequence;

Since the actual data is below 'f["2k8v"]..[1]' I would suggest to 
simplify access by shifting the content upwards:

info = f["2k8v"]..[1];
print info..sequence;

Regards,
Rolf

-- 

Rolf Huehne
Postdoc

Leibniz Institute on Aging - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany

Phone:   +49 3641 65 6205
Fax:     +49 3641 65 6210
E-Mail:  rhue...@leibniz-fli.de
Website: http://www.leibniz-fli.de

           Scientific Director: Prof. Dr. K. Lenhard Rudolph
        Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Burkhard Zinner

VAT No: DE 153 925 464
Register of Associations: No. 230296, Amtsgericht Jena
Tax Number: 162/141/08228


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to