-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (36 loc) · 1.3 KB
/
main.py
File metadata and controls
55 lines (36 loc) · 1.3 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python3
from dataGather import gatherRedditData,cleanUp
from dataAnalysis import runDataAnalysis
from sql import pushToDataBase
from sql.retrieveData import getData
import config
import post.post as p
import sys
#Connect to Reddit and run the intial data collections
#Results should be a bunch of txt files with thread titles and comments inside of them
def dataCollect():
for item in config.targetSub:
gatherRedditData(config.limit, item)
#Here we scan each of the txt docs and count the total number of times a word is used
runDataAnalysis(item)
#SQL DataPush
pushToDataBase(item)
#REMOVE AND CLEAN
cleanUp(config.cleanUp, item, 'txt') #Txt docs
cleanUp(config.cleanUp, item, 'xml') #XML docs
def postData():
for item in config.targetSub:
postdata = getData(item)
p.postToReddit(item,postdata)
if __name__== "__main__":
if not len(sys.argv) == 1:
ValueError('Expected one argument')
arg =str(sys.argv[1])
if not type(arg) == str:
raise TypeError("Must be a string")
# if not arg == 'post' or not arg == 'gather':
# raise ValueError('exepcted args are post and gather')
if arg == 'post':
postData()
elif arg == 'gather':
dataCollect()