title: How to stream first 5 tweets? And how to stream only those users enabled geographic info and real name?
body: <p>I am trying to use tweepy to stream some specific data, I read the tweepy documentation but wasn't helping. I would like to do the followings:</p>
  
  <ol>
  <li>Printout only the first 5 tweets, then stop the script. I tried
  to use a "for" loop, but it keeps streaming. </li>
  <li>I would like to stream only those tweets on a specific topic (ie: car) for those
  Twitter users who i) have enabled the geographic info and ii) used
  real name as an username.</li>
  <li>Export and append the streamed tweets into a csv file</li>
  </ol>
  
  <p>Any directions as to how I can learn or approach this will be greatly appreciated.</p>
  
  <pre><code>from tweepy import Stream
  from tweepy import OAuthHandler
  from tweepy.streaming import StreamListener
  import sys
  
  ckey = ""
  csecret = ""
  atoken = ""
  asecret = ""
  
  class listener(StreamListener):
      def on_data(self, data):
          print data
          return True
      def on_error(self, status):
          print status
  
  counter = 0
  for counter in range (0, 5):
      counter += 1
      auth = OAuthHandler(ckey, csecret)
      auth.set_access_token(atoken, asecret)
      twitterStream = Stream(auth, listener())
      twitterStream.filter(track=["car"])
  </code></pre>
  
  <p>Edited version:</p>
  
  <pre><code>import tweepy
  import time
  
  ckey = ""
  csecret = ""
  atoken = ""
  asecret = ""
  
  OAUTH_KEYS = {'consumer_key':ckey, 'consumer_secret':csecret,
      'access_token_key':atoken, 'access_token_secret':asecret}
  auth = tweepy.OAuthHandler(OAUTH_KEYS['consumer_key'], OAUTH_KEYS['consumer_secret'])
  api = tweepy.API(auth)
  
  for tweet in tweepy.Cursor(api.search, q='car', since='2014-09-01', until='2014-09-02').items(5):
      if tweet.geo != None:
          print tweet.geo, tweet.author.screen_name
  </code></pre>