title: Filtering Twitter data using Tweepy
body: <p>I've used Marco Bonzanini's tutorial on mining Twitter data : <a href="https://marcobonzanini.com/2015/03/02/mining-twitter-data-with-python-part-1/" rel="nofollow noreferrer">https://marcobonzanini.com/2015/03/02/mining-twitter-data-with-python-part-1/</a></p>
  
  <pre><code>class MyListener(StreamListener):
  
      def on_data(self, data):
          try:
              with open('python.json', 'a') as f:
                  f.write(data)
                  return True
          except BaseException as e:
              print(&amp;quot;Error on_data: %s&amp;quot; % str(e))
          return True
  
      def on_error(self, status):
          print(status)
          return True
  </code></pre>
  
  <p>and used the "follow" parameter of the filter method to retrieve the tweets produced by this specific ID : </p>
  
  <pre><code>twitter_stream = Stream(auth, MyListener())
  twitter_stream.filter(follow=["63728193"#random Twitter ID])
  </code></pre>
  
  <p>However, it does not seem to fulfill the mission since it not only returns the tweets &amp; retweets created by the ID, but also every tweet wherein the ID is mentioned (i.e. retweets). That is not what I want.</p>
  
  <p>I'm sure there must be a way to do it since there is a "screen_name" field in the json file given by Twitter. That screen_name field gives the name of the creator of the Tweet. I just have to find how to filter the data on this screen_neame field.</p>