Commit c0d07e9f authored by Cody Zacharias's avatar Cody Zacharias Committed by GitHub

Update tweep.py

parent cdff8e7a
...@@ -5,6 +5,7 @@ import argparse ...@@ -5,6 +5,7 @@ import argparse
import aiohttp import aiohttp
import asyncio import asyncio
import async_timeout import async_timeout
import csv
import datetime import datetime
import json import json
import sys import sys
...@@ -94,6 +95,12 @@ async def getTweets(init): ...@@ -94,6 +95,12 @@ async def getTweets(init):
output = "{} {} {} {} <{}> {}".format(tweetid, date, time, timezone, username, text) output = "{} {} {} {} <{}> {}".format(tweetid, date, time, timezone, username, text)
if arg.o != None: if arg.o != None:
if arg.csv:
dat = [tweetid, date, time, timezone, username, text]
with open(arg.o, "a", newline='') as csv_file:
writer = csv.writer(csv_file, delimiter=",")
writer.writerow(dat)
else:
print(output, file=open(arg.o, "a")) print(output, file=open(arg.o, "a"))
print(output) print(output)
...@@ -120,6 +127,7 @@ if __name__ == "__main__": ...@@ -120,6 +127,7 @@ if __name__ == "__main__":
ap.add_argument("--tweets", help="Display Tweets only.", action="store_true") ap.add_argument("--tweets", help="Display Tweets only.", action="store_true")
ap.add_argument("--verified", help="Display Tweets only from verified users (Use with -s).", action="store_true") ap.add_argument("--verified", help="Display Tweets only from verified users (Use with -s).", action="store_true")
ap.add_argument("--users", help="Display users only (Use with -s).", action="store_true") ap.add_argument("--users", help="Display users only (Use with -s).", action="store_true")
ap.add_argument("--csv", help="Write as .csv file.", action="store_true")
arg = ap.parse_args() arg = ap.parse_args()
if arg.u is not None: if arg.u is not None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment