[Tutor] getting and using information dict objects

Matthew Johnson mcooganj at gmail.com
Sun Feb 24 03:40:42 CET 2013


For the sake of those who finds this thread -- the date / value pairs
can be printed by the following:

import fred

fred.key(fredKey)

gnpObvs = fred.observations('GNPCA')

for i in range(1, len(gnpObvs['observations']['observation'])):
    print gnpObvs['observations']['observation'][i]['date'],
gnpObvs['observations']['observation'][i]['value']

mj

On 24 February 2013 10:51, Matthew Johnson <mcooganj at gmail.com> wrote:
> Thanks very much; hopefully that's the boost i need to get rolling.
>
> Best regards
>
> matt
>
> On 24/02/2013, at 10:40 AM, Robert Sjoblom <robert.sjoblom at gmail.com> wrote:
>
>>> I am fairly sure i am querying the FRED API, but i am unsure how to
>>> _access and use_ the dict objects that it is returning. For example,
>>> how would i just print out values?
>>
>> If it's a dict object, the standard dictionary behavior and methods
>> should work. I've not looked closely at the FRED API, but something
>> like (untested):
>> for key in dictionary:
>>    print(key, dictionary[key])
>>
>> could possibly get you started.
>>
>> --
>> best regards,
>> Robert S.


More information about the Tutor mailing list