Change return value of datecsv.getTweetsByDate() to a list of tweets rather than None
Move CSV output function to tools.printCSV()
This commit is contained in:
parent
6a1cce1b97
commit
e2ab015218
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
import tools
|
import tools
|
||||||
|
|
||||||
import csv, sys, datetime
|
import sys, datetime
|
||||||
|
|
||||||
def checkDate(date):
|
def checkDate(date):
|
||||||
try:
|
try:
|
||||||
|
@ -71,11 +71,8 @@ def queryBuilder(strings = [], fr = "", to = ""):
|
||||||
|
|
||||||
def getTweetsByDate(strings = [], path = tools.config.dbpath, fr = "", to = ""):
|
def getTweetsByDate(strings = [], path = tools.config.dbpath, fr = "", to = ""):
|
||||||
db = tools.dbHelper(path)
|
db = tools.dbHelper(path)
|
||||||
tweets = db.executeQuery(queryBuilder(strings,fr,to))
|
return db.executeQuery(queryBuilder(strings,fr,to))
|
||||||
writer = csv.writer(sys.stdout)
|
|
||||||
|
|
||||||
writer.writerows(tweets)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
strings, fr, to = dateArgs()
|
strings, fr, to = dateArgs()
|
||||||
getTweetsByDate(strings = strings, fr = fr, to = to)
|
tools.printCSV(getTweetsByDate(strings = strings, fr = fr, to = to))
|
||||||
|
|
7
tools.py
7
tools.py
|
@ -1,6 +1,6 @@
|
||||||
import config
|
import config
|
||||||
|
|
||||||
import os, sqlite3, tweepy
|
import csv, os, sqlite3, sys, tweepy
|
||||||
|
|
||||||
class dbObject:
|
class dbObject:
|
||||||
|
|
||||||
|
@ -81,3 +81,8 @@ def parseArgs(argv):
|
||||||
args += [a]
|
args += [a]
|
||||||
|
|
||||||
return args, path
|
return args, path
|
||||||
|
|
||||||
|
def printCSV(inlist):
|
||||||
|
writer = csv.writer(sys.stdout)
|
||||||
|
writer.writerows(inlist)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue