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:
Klaus-Uwe Mitterer 2015-04-24 23:33:42 +02:00
parent 6a1cce1b97
commit e2ab015218
2 changed files with 9 additions and 7 deletions

View file

@ -3,7 +3,7 @@
import tools
import csv, sys, datetime
import sys, datetime
def checkDate(date):
try:
@ -71,11 +71,8 @@ def queryBuilder(strings = [], fr = "", to = ""):
def getTweetsByDate(strings = [], path = tools.config.dbpath, fr = "", to = ""):
db = tools.dbHelper(path)
tweets = db.executeQuery(queryBuilder(strings,fr,to))
writer = csv.writer(sys.stdout)
writer.writerows(tweets)
return db.executeQuery(queryBuilder(strings,fr,to))
if __name__ == "__main__":
strings, fr, to = dateArgs()
getTweetsByDate(strings = strings, fr = fr, to = to)
tools.printCSV(getTweetsByDate(strings = strings, fr = fr, to = to))

View file

@ -1,6 +1,6 @@
import config
import os, sqlite3, tweepy
import csv, os, sqlite3, sys, tweepy
class dbObject:
@ -81,3 +81,8 @@ def parseArgs(argv):
args += [a]
return args, path
def printCSV(inlist):
writer = csv.writer(sys.stdout)
writer.writerows(inlist)