Home:ALL Converter>How to get tweepy output into Excel?

How to get tweepy output into Excel?

Ask Time:2012-10-22T06:38:49         Author:Peter Trasher

Json Formatter

I'm a newbie in programming, but i hope you can help me with my problem. I'm trying to analyse tweets using tweepy/python/stream.api and R (the statistic program).

Right know the stream listener is working, but I can't use the output...

This is the script I'm running:

import tweepy

consumer_key="..."
consumer_secret="..."
access_key = "..."
access_secret = "..."


auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)

class CustomStreamListener(tweepy.StreamListener):
    def on_status(self, status):
        print status.text

    def on_error(self, status_code):
        print >> sys.stderr, 'Encountered error with status code:', status_code
        return True # Don't kill the stream

    def on_timeout(self):
        print >> sys.stderr, 'Timeout...'
        return True # Don't kill the stream

sapi = tweepy.streaming.Stream(auth, CustomStreamListener())
sapi.filter(track=['...'])

As a result, I don't get the full tweets (only the first 50 characters), and I can't see the time when it was tweeted. How can i fix this, and is it possible to somehow "print" the output into an Excel file?

Author:Peter Trasher,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/13002903/how-to-get-tweepy-output-into-excel
RParadox :

Write the output into .csv file or use the xlrd package. As far as the 50 characters is concerned I don't know. Looks like this has to do with the library.",
2012-10-21T23:27:23
yy