forked from sd17fall/TextMining
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pickling.py
25 lines (22 loc) · 1.03 KB
/
Pickling.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
filePath = "C:/Users/sokuno/TextMining"
import os
import pickle
import twitter
from TwitterKeys import *
def PickleBuddy():
files = os.listdir(filePath) # make a list of all the files that already exist
if not "cachedData.pickle" in files:
#setting up api using twitter key info from TwitterKey.py
api = twitter.Api(consumer_key=CONSUMER_KEY,
consumer_secret=CONSUMER_SECRET,
access_token_key=ACCESS_TOKEN_KEY,
access_token_secret=ACCESS_TOKEN_SECRET)
fullTweet = api.GetSearch(term='#inspirationalquotes', raw_query=None, geocode=None, since_id=None, max_id=None, until=None, since=None, count=100, lang=None, locale=None, result_type='recent', include_entities=None)
pickles = open('cachedData.pickle', 'wb')
pickle.dump(fullTweet, pickles)
pickles.close
def unPickleBuddy():
ultimateUnPickle = []
unpickles = open(filePath+'/cachedData.pickle', 'rb')
untest = pickle.load(unpickles)
return untest