Re: Difficulty w/json keys

2010-04-23 Thread Red
On Apr 23, 1:17 pm, Terry Reedy wrote: > On 4/23/2010 10:20 AM, Red wrote: > > > My apologies for what is probably a simple question to most on this > > group. However, I am new to python and very new to json. > > > I am trying to read in a json file from a twitter download. There are, > > general

Re: Difficulty w/json keys

2010-04-23 Thread Red
Thanks to Cliff and Rolando who saw where my real problem was. Terry,Jim: I had not seen the tutorial before, so I'll have to dig into that as well. So little time. Cheers On Apr 23, 10:06 am, "J. Cliff Dyer" wrote: > You need to know what your input data actually looks like, and the best > th

Re: Difficulty w/json keys

2010-04-23 Thread Terry Reedy
On 4/23/2010 10:51 AM, Jim Byrnes wrote: I can't help you directly with your problem but have you seen this: http://arstechnica.com/open-source/guides/2010/04/tutorial-use-twitters-new-real-time-stream-api-in-python.ars Yes. Ignore the part about push versus pull (you are already doing the l

Re: Difficulty w/json keys

2010-04-23 Thread Terry Reedy
On 4/23/2010 10:20 AM, Red wrote: My apologies for what is probably a simple question to most on this group. However, I am new to python and very new to json. I am trying to read in a json file from a twitter download. There are, generally, two types of lines: those lines with "text" and the oth

Re: Difficulty w/json keys

2010-04-23 Thread J. Cliff Dyer
You need to know what your input data actually looks like, and the best thing for that is a little bit of formatting. I bet you can figure out the problem yourself, once you see the structure of your data more clearly. I've reformatted the JSON for you to help out. On Fri, 2010-04-23 at 07:20

Re: Difficulty w/json keys

2010-04-23 Thread Rolando Espinoza La Fuente
On Fri, Apr 23, 2010 at 10:20 AM, Red wrote: [...] > for line in f: >        j = json.loads(line) >        if 'text' in j: >                if 'lang' in j: >                        lang = j['lang'] >                        print "language", lang >                text = j['text'] "lang" key is in

Re: Difficulty w/json keys

2010-04-23 Thread Jim Byrnes
Red wrote: My apologies for what is probably a simple question to most on this group. However, I am new to python and very new to json. I am trying to read in a json file from a twitter download. There are, generally, two types of lines: those lines with "text" and the other lines. I am only in

Difficulty w/json keys

2010-04-23 Thread Red
My apologies for what is probably a simple question to most on this group. However, I am new to python and very new to json. I am trying to read in a json file from a twitter download. There are, generally, two types of lines: those lines with "text" and the other lines. I am only interested in t