Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. class MyStreamer(TwythonStreamer):
  2. def on_success(self, data):
  3. if data['lang'] == 'en':
  4. tweets.append(data)
  5. saveFile = open('twitterDataFile.py','a',encoding='utf-8')
  6. saveFile.write(str(data))
  7. saveFile.write('\n')
  8. saveFile.close()
  9. return True
  10.  
  11. def read_ftweets():
  12. counter = 0
  13. with open('twitterDataFile.py','r',encoding = 'ISO-8859-1') as f:
  14. for line in f:
  15. counter = counter + 1
  16. ftweets.append(line)
  17.  
  18. #The twitterDataFile file is the file I made to stream tweets into, it was twitterDataFile.txt when it should've been #twitterDataFile.py. Now it works with that code Fiona put on moodle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement