title: twitter stream JSON decoding
body: <p>So, I have created geo map box from which I gather Tweets, and I want to get even more precise locations using long;lat.</p>
  
  <p>I need to get out only coordinates (long;lat separate) without rest of "coordinates" data.</p>
  
  <p>Im using <em>tweepy</em> and I understand Iam not decoding it right but I can't seem to understand why It doesn't work.</p>
  
  <p>and this where and how i keep failing</p>
  
  <p><strong>input JSON</strong></p>
  
  <pre><code>    {  
     u'contributors':None,
     u'truncated':False,
     u'text':   u'Stundas tikai l\u012bdz 12.00 \U0001f64c\U0001f389\U0001f389\U0001f389 (@ R\u012bgas Valsts v\u0101cu \u0123imn\u0101zija - @rvv_gimnazija in R\u012bga) https://t.co/XCp8OzqQgk',
     u'in_reply_to_status_id':None,
     u'id':599100313690320896,
     u'favorite_count':0,
     u'source':   u'&lt;a href="http://foursquare.com" rel="nofollow"&gt;Foursquare&lt;/a&gt;',
     u'retweeted':False,
     u'coordinates':{  
        u'type':u'Point',
        u'coordinates':[  
           24.062859,
           56.94697
        ]
     },
  </code></pre>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>class listener(StreamListener):
      def on_data(self, data):
  
          tweet = json.loads(data)
  
  
          #print time.time()
          text = tweet['text']
          name = tweet['user']['name']
          screenName = tweet['user']['screen_name']
          location = tweet['coordinates']['coordinates'][0]
  
          print name.encode('utf-8')
          print text.encode('utf-8')
          print location
          print '\n'
  
          # into the data file
          with open('minedData', 'a') as outfile:
              json.dump({ 'location':location, 'time': time.time(), 'screenName': screenName, 'text': text, 'name': name}, outfile, indent = 4, sort_keys=True)
              #outfile.write(',')
              outfile.write('\n')
  
          return True
  
      def on_error(self, status):
          print status
  
  
  auth = OAuthHandler(ckey, csecret)
  auth.set_access_token(atoken, asecret)
  twitterStream = Stream(auth, listener())
  twitterStream.filter(locations=[23.47,56.66,25.148411,57.407558])
  </code></pre>
  
  <p><strong>The error</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "loc3.py", line 45, in &lt;module&gt;
      twitterStream.filter(locations=[23.47,56.66,25.148411,57.407558])
    File "/Library/Python/2.7/site-packages/tweepy/streaming.py", line 428, in filter
      self._start(async)
    File "/Library/Python/2.7/site-packages/tweepy/streaming.py", line 346, in _start
      self._run()
    File "/Library/Python/2.7/site-packages/tweepy/streaming.py", line 255, in _run
      self._read_loop(resp)
    File "/Library/Python/2.7/site-packages/tweepy/streaming.py", line 309, in _read_loop
      self._data(next_status_obj)
    File "/Library/Python/2.7/site-packages/tweepy/streaming.py", line 289, in _data
      if self.listener.on_data(data) is False:
    File "loc3.py", line 23, in on_data
      location = tweet['coordinates']['coordinates'][0]
  TypeError: 'NoneType' object has no attribute '__getitem__'
  </code></pre>