I am using a python script to extract the tweets from twitter. I want to write the output into a text file.
When I run the .py file from Anaconda command prompt, it shows me the output in the command prompt. But when I try to write the same output to a file, it doesn't write anything.
C:\Users\akjain>python c:\Akash\TweetExtract.py >> twitter_data.txt
I have tried to open the Ananconda as an Administrator too. Also created the text file in the same folder where I have python script before running the script.
I also tried the below code but this also did not work.
C:\windows\system32>python c:\Akash\GartnerTweetExtract.py > c:\Akash\twitter_data.txt
Edit:
Code to print the ouput to command prompt which is inside my python script is as follows:
#This is a basic listener that just prints received tweets to stdout.
class StdOutListener(StreamListener):
def on_data(self, data):
print (data)
return True
def on_error(self, status):
print (status)
Any help would be really appreciated.
Regards,
Akash