From e2a1a2e5a5ed5373911b7151a3762f86c55989c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Dur=C3=A1n?= Date: Sun, 13 Oct 2019 13:35:07 +0200 Subject: [PATCH] Update to process tweet.js file Now twitter doesn't give you a tweets.csv file, instead of it, they give you a tweet.js file with a few changes. I have updated the script to work with the new format. --- deletetweets.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/deletetweets.py b/deletetweets.py index 3351a12..6f95c78 100644 --- a/deletetweets.py +++ b/deletetweets.py @@ -6,18 +6,19 @@ import time import os import twitter +import json from dateutil.parser import parse __author__ = "Koen Rouwhorst" -__version__ = "0.1" +__version__ = "0.2" def delete(api, date, r): - with open("tweets.csv") as file: + with open("tweet.js") as file: count = 0 - for row in csv.DictReader(file): - tweet_id = int(row["tweet_id"]) - tweet_date = parse(row["timestamp"], ignoretz=True).date() + for row in json.load(file): + tweet_id = int(row["id"]) + tweet_date = parse(row["created_at"], ignoretz=True).date() if date != "" and tweet_date >= parse(date).date(): continue