{"id":1439,"date":"2019-11-15T18:34:35","date_gmt":"2019-11-15T18:34:35","guid":{"rendered":"http:\/\/redpincushion.us\/blog\/?p=1439"},"modified":"2019-11-15T18:34:35","modified_gmt":"2019-11-15T18:34:35","slug":"deleting-tweets-non-techie-starts-her-personal-information-environmentalism-journey-with-lots-of-helpre-post-from-2017","status":"publish","type":"post","link":"https:\/\/redpincushion.us\/blog\/technology-2\/deleting-tweets-non-techie-starts-her-personal-information-environmentalism-journey-with-lots-of-helpre-post-from-2017\/","title":{"rendered":"Deleting tweets (non-techie starts her personal information environmentalism journey\u2013with lots of help)[re-post from 2017]"},"content":{"rendered":"<p>[This is a re-post from our old Digital Learning blog, which is now defunct. No changes were made to the original post]<\/p>\n<p>Confession: I\u2019m not a coder. I haven\u2019t coded since grad school, when I learned how to write basic HTML so I could build wikis (back then, wikis required you to write HTML code to make them work).<\/p>\n<p>So when I saw Kris Schaffer\u2019s article \u201c<a href=\"https:\/\/pushpullfork.com\/i-deleted-tweets\/\">I deleted 40,000 tweets last week. Here\u2019s why (and how)<\/a>,\u201d I thought, \u201cthat\u2019s cool and I\u2019ll never be able to do it because it requires coding\u2026\u2026.in Python.\u201d<\/p>\n<p>I\u2019m out.<\/p>\n<p>But in the last year, for reasons I probably don\u2019t have to tell you, I\u2019ve spent a lot of time thinking about what it means to have data \u201cout there\u201d on the web, in the hands of platform companies (like Facebook, Twitter, Amazon, Ancestry, etc. etc. etc.), and in the databases of who-knows-who-purchased-my-data-from-platform-companies. Or in the hands of trolls, harassers, or anyone else who wishes to do me harm. Or wishes to do my family harm.<\/p>\n<p>I\u2019ve also been wondering a lot about how higher education institutions like Middlebury should be thinking about, working with, managing, and protecting student data as students engage with Middlebury. This was the impetus behind my recent writing on <a href=\"https:\/\/er.educause.edu\/articles\/2017\/8\/digital-sanctuary-protection-and-refuge-on-the-web\">Digital Sanctuary<\/a>.<\/p>\n<p>As I\u2019ve thought about my own digital footprint, I\u2019ve been inspired by <a href=\"https:\/\/pushpullfork.com\/digital-minimalism-being-deliberate-about-digital-identity\/\">Kris Schaffer\u2019s digital minimalism<\/a> and <a href=\"https:\/\/er.educause.edu\/articles\/2017\/10\/info-environmentalism-an-introduction\">Mike Caulfield\u2019s information environmentalism<\/a> (in this case, it\u2019s more of a personal information environmentalism\u2013improving my personal information environments). Frankly, it was past time to put action behind these reflections. It was time to start minimizing and deleting. I recognize that deleting old tweets is just a start, and it doesn\u2019t mean that my data disappears completely. I know Twitter will keep a copy of my data that I will not be able to delete. But deleting old tweets from my public profile, and from the advanced search functions of Twitter, will at least make those tweets inaccessible to others who might try to do harm.<\/p>\n<p>But\u2026coding.<\/p>\n<p>Twitter doesn\u2019t make it easy for you to delete old stuff. Even services that offer to help you delete old tweets\u2013and there are many\u2013 can only delete a specific number (3,200; because Twitter won\u2019t allow them to delete any more than that). Your only recourse if you want to delete tweets, say, between 2008 and 2015, is to serve up code through Twitter\u2019s API that will tell Twitter to delete your old stuff.<\/p>\n<p>Thank goodness for <a href=\"https:\/\/twitter.com\/krisshaffer\">Kris Schaffer<\/a> and his unending patience. I tried to follow his step-by-step instructions for writing code to delete old tweets through Twitter\u2019s API but I was too much of a Python novice to know what I was doing. I needed help and he graciously walked me through the basics I needed to move into the deleting stage.<\/p>\n<p>The good news: As I write this blog post, I am watching my old tweets being deleted in real time. Celebratory happy dance!<\/p>\n<p>Since my starting point for this process was \u201cabsolute newbie,\u201d <a href=\"https:\/\/pushpullfork.com\/i-deleted-tweets\/\">I\u2019m going to walk you through Kris\u2019s process<\/a>, but add steps that were not as obvious to me on the road to tweet-deleting success.<\/p>\n<p><strong><span class=\"lts_dropcap  \">1)<\/span><\/strong> <strong>First things first: Download your twitter archive<\/strong> (which has text of all of your tweets) and unzip the folder. As Kris says, doing this allows you to save a copy of any tweets you\u2019re planning to delete (oh, sweet memories), but also this is the file that will guide the Twitter deletions. Instructions for downloading the twitter archive are here: <a href=\"https:\/\/support.twitter.com\/articles\/20170160?lang=en#\">https:\/\/support.twitter.com\/articles\/20170160?lang=en#<\/a><\/p>\n<p>When you download and unzip your tweet archive, the folder will be named something long and ugly. I\u2019d recommend changing it to something more typable (you will have to type it later), but keep the tweets.csv file inside the folder named tweets.csv.<\/p>\n<p><strong><span class=\"lts_dropcap  \">2)<\/span> Next, you\u2019ll create an app on Twitter<\/strong> that uses Twitter\u2019s API to tell it to delete tweets. Here, I\u2019ll copy Kris\u2019 instructions, because they are simple and straightforward:<\/p>\n<p>\u201cNext, create a new app on <a href=\"https:\/\/apps.twitter.com\/\">apps.twitter.com<\/a>. Just click \u201cCreate New App\u201d; then provide a name for your app (\u201ctweet deleter\u201d is fine), description (same), and website (your website, or even the URL for your Twitter account).<\/p>\n<p>Once you\u2019ve created your account, you need to get a few authorization codes to link your Python script with your Twitter app. Open the \u201cKeys and Access Tokens\u201d tab, where you\u2019ll find a Consumer Key (API Key) and a Consumer Secret (API Secret). You\u2019ll also probably need to click on \u201cGenerate My Access Token and Token Secret\u201d to generate the Access Token and Access Secret. Keep this tab open in your browser so you can copy these codes into your Python script, and be sure not to share these codes with others, or they\u2019ll be able to access your account.\u201d<\/p>\n<p><strong><span class=\"lts_dropcap  \">3)<\/span> Here\u2019s where things get fun(ky):<\/strong> You\u2019re going to need to be able to edit Python scripts and to run Python. <strong>THIS IS NOT AS SCARY AS IT SEEMS AT FIRST!<\/strong>\u00a0You\u2019ll need a Python editor (you can\u2019t just use a Mac- or Windows-issued text editor\u2013 that was my first rookie mistake). You\u2019ll need a text editor that understands Python quirks. I downloaded and am using <a href=\"http:\/\/www.sublimetext.com\/\">Sublime Text<\/a> and I really like it. So, download a Python editor like <a href=\"http:\/\/www.sublimetext.com\/\">Sublime Text<\/a>.<\/p>\n<p>You\u2019ll also need a Python environment in which to run your code. Following Kris\u2019 recommendation, <a href=\"https:\/\/www.anaconda.com\/download\/\">I downloaded and installed Anaconda<\/a>. Once you\u2019ve done so (and it took me an embarrassingly long time to figure this out), click <strong>Environments<\/strong> on the left sidebar and click the arrow next to \u201croot.\u201d Click <strong>Open with Python<\/strong>, and a new Python terminal window will open up. This is where you\u2019ll input your code later.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2168\" src=\"https:\/\/i2.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-2.56.45-PM.png?resize=646%2C295\" sizes=\"auto, (max-width: 646px) 100vw, 646px\" srcset=\"https:\/\/i2.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-2.56.45-PM.png?w=646&amp;ssl=1 646w, https:\/\/i2.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-2.56.45-PM.png?resize=300%2C137&amp;ssl=1 300w\" alt=\"\" width=\"646\" height=\"295\" data-attachment-id=\"2168\" data-permalink=\"https:\/\/digitallearning.middcreate.net\/tips\/deleting-tweets-non-techie-starts-her-personal-information-environmentalism-journey-with-lots-of-help\/attachment\/screen-shot-2017-11-07-at-2-56-45-pm\/\" data-orig-file=\"https:\/\/i2.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-2.56.45-PM.png?fit=646%2C295&amp;ssl=1\" data-orig-size=\"646,295\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screen Shot 2017-11-07 at 2.56.45 PM\" data-image-description=\"\" data-medium-file=\"https:\/\/i2.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-2.56.45-PM.png?fit=300%2C137&amp;ssl=1\" data-large-file=\"https:\/\/i2.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-2.56.45-PM.png?fit=646%2C295&amp;ssl=1\" data-recalc-dims=\"1\" \/><\/p>\n<p><strong><span class=\"lts_dropcap  \">4<\/span><\/strong>) <strong>Next: Let\u2019s code! <\/strong><\/p>\n<p>We\u2019ll be using most of <a href=\"https:\/\/pushpullfork.com\/i-deleted-tweets\/\">Kris\u2019 code<\/a>, so I recommend that you copy and paste his code into a Sublime Text window (or whichever code editor you\u2019re using). Go ahead and open a Python environment as well, using Anaconda (or your Python environment of choice).<\/p>\n<p>You\u2019ll start by installing Tweepy, a code framework for working with Twitter\u2019s API. In your Python terminal, you\u2019ll see three arrows pointing to the right, like this:\u00a0\u00a0<strong>&gt;&gt;&gt;<\/strong><\/p>\n<p>Next to those arrows, type:<\/p>\n<p>pip install tweepy<\/p>\n<p>and then press <strong>Enter<\/strong> on your keyboard. You\u2019ll see a bunch of stuff happen on the Python terminal. Tweepy should now be installed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2177\" src=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.06.43-PM-1-e1510156965902-1024x258.png?resize=666%2C168\" sizes=\"auto, (max-width: 666px) 100vw, 666px\" srcset=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.06.43-PM-1-e1510156965902.png?resize=1024%2C258&amp;ssl=1 1024w, https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.06.43-PM-1-e1510156965902.png?resize=300%2C76&amp;ssl=1 300w, https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.06.43-PM-1-e1510156965902.png?resize=768%2C193&amp;ssl=1 768w, https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.06.43-PM-1-e1510156965902.png?w=1140&amp;ssl=1 1140w\" alt=\"\" width=\"666\" height=\"168\" data-attachment-id=\"2177\" data-permalink=\"https:\/\/digitallearning.middcreate.net\/tips\/deleting-tweets-non-techie-starts-her-personal-information-environmentalism-journey-with-lots-of-help\/attachment\/screen-shot-2017-11-07-at-8-06-43-pm-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.06.43-PM-1-e1510156965902.png?fit=1140%2C287&amp;ssl=1\" data-orig-size=\"1140,287\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screen Shot 2017-11-07 at 8.06.43 PM\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.06.43-PM-1-e1510156965902.png?fit=300%2C76&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.06.43-PM-1-e1510156965902.png?fit=690%2C174&amp;ssl=1\" data-recalc-dims=\"1\" \/><\/p>\n<p>Now, go to your text editor (like Sublime Text) and copy\/paste in the following code:<\/p>\n<p>import tweepy<br \/>\nimport csv<\/p>\n<p>consumer_key = \u201d<br \/>\nconsumer_secret = \u201d<br \/>\naccess_key = \u201d<br \/>\naccess_secret = \u201d<\/p>\n<p>See where it says<b> consumer_key<\/b>, <b>consumer_secret<\/b>, <b>access_key<\/b>, and <b>access_secret<\/b>? Between the single quotes marks on each, you\u2019ll paste in the codes you got when you created your Twitter deletion app in Step 2.<\/p>\n<p>So the code in your text editor will look something more like this:<\/p>\n<p>import tweepy<br \/>\nimport csv<\/p>\n<p>consumer_key = \u2018394nkdr93jfks9fjajfskefofkeajfke\u2019<br \/>\nconsumer_secret = \u2018kdfajkldfjaioejfiaofanvanvnvpaei29jdna\u2019<br \/>\naccess_key = \u20189rajioajnfanvioaejie9oajf\u2019<br \/>\naccess_secret = \u201992jioanfkanfalaionn;a;\u2019<\/p>\n<p><strong>Now, I just put goobledy-gook in there,<\/strong> but you\u2019ll paste in the actual numbers provided on your apps.twitter.com page. Basically, you\u2019ve told Tweepy that these are the credentials it\u2019ll need to engage with the Twitter API for your Twitter account\/tweets.<\/p>\n<p>Still with me? Whew! Hang in there.<\/p>\n<p>Now that Tweepy knows that we\u2019re going to be coding for your Twitter account, based on the credentials you inputted, let\u2019s tell Tweepy that it\u2019ll be reading a .csv file to know which tweets should be marked for deletion.<\/p>\n<p>def read_csv(file):<\/p>\n<p>\u201c\u201d\u201d<\/p>\n<p>reads a CSV file into a list of lists<\/p>\n<p>\u201c\u201d\u201d<\/p>\n<p>with open(file, encoding = \u2018utf-8\u2019) as csvfile:<\/p>\n<p>reader = csv.reader(csvfile, delimiter = \u2018,\u2019)<\/p>\n<p>rows = []<\/p>\n<p>for line in reader:<\/p>\n<p>row_data = []<\/p>\n<p>for element in line:<\/p>\n<p>row_data.append(element)<\/p>\n<p>if row_data != []:<\/p>\n<p>rows.append(row_data)<\/p>\n<p>rows.pop(0)<\/p>\n<p>return(rows)<\/p>\n<p>&nbsp;<\/p>\n<p>You don\u2019t change anything about this code (including the indentations). Just input it directly as it\u2019s written (copy\/paste into and from Sublime Text) and press <strong>Enter<\/strong>.<\/p>\n<p>On Kris\u2019 blog post, he tells you to run an authentication function but, after I ran into multiple issues with the function, he said I didn\u2019t need to run that function. So next is to authenticate Tweepy to Twitter.<\/p>\n<p>Here\u2019s the code, that you\u2019ll paste next to the <strong>&gt;&gt;&gt;<\/strong>:<\/p>\n<p>auth = tweepy.OAuthHandler(consumer_key, consumer_secret)<br \/>\nauth.set_access_token(access_key, access_secret)<br \/>\napi = tweepy.API(auth)<br \/>\nprint(\u201cAuthenticated as: %s\u201d % api.me().screen_name)<\/p>\n<p>Again, you don\u2019t have to change a thing in this code\u2013input it exactly as it is (put in your Python editor first, then copy\/paste into your Python terminal). You\u2019ve already told Tweepy your consumer key\/secret and authorization key\/secret, so it should be good to go. Success will look like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2171\" src=\"https:\/\/i1.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.31.04-PM.png?resize=659%2C122\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" srcset=\"https:\/\/i1.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.31.04-PM.png?resize=1024%2C190&amp;ssl=1 1024w, https:\/\/i1.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.31.04-PM.png?resize=300%2C56&amp;ssl=1 300w, https:\/\/i1.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.31.04-PM.png?resize=768%2C143&amp;ssl=1 768w, https:\/\/i1.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.31.04-PM.png?w=1054&amp;ssl=1 1054w\" alt=\"\" width=\"659\" height=\"122\" data-attachment-id=\"2171\" data-permalink=\"https:\/\/digitallearning.middcreate.net\/tips\/deleting-tweets-non-techie-starts-her-personal-information-environmentalism-journey-with-lots-of-help\/attachment\/screen-shot-2017-11-07-at-8-31-04-pm\/\" data-orig-file=\"https:\/\/i1.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.31.04-PM.png?fit=1054%2C196&amp;ssl=1\" data-orig-size=\"1054,196\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screen Shot 2017-11-07 at 8.31.04 PM\" data-image-description=\"\" data-medium-file=\"https:\/\/i1.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.31.04-PM.png?fit=300%2C56&amp;ssl=1\" data-large-file=\"https:\/\/i1.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.31.04-PM.png?fit=690%2C128&amp;ssl=1\" data-recalc-dims=\"1\" \/><\/p>\n<p>Now, tell Tweepy and the Twitter API to read your downloaded tweet archive, by inputting this at the <strong>&gt;&gt;&gt;<\/strong>:<\/p>\n<p>tweets = read_csv(\u2018\/path\/to\/file\/tweets.csv\u2019)<\/p>\n<p>Where it says \/path\/to\/file\/tweets.csv, you\u2019ll want to replace that text with the directory path for the tweets.csv file that you downloaded earlier. Remember how I said that you\u2019d want to rename the unzipped folder to something nice? This is why. For me, my code was:<\/p>\n<p>tweets = read_csv(\u2018\/users\/myusername\/downloads\/twitterarchive\/tweets.csv\u2019)<\/p>\n<p>I renamed my unzipped folder \u201ctwitterarchive\u201d instead of the long title that folder originally had. Need help figuring out the directory for your file? On a Mac, you can right-click the file and select <strong>Get Info<\/strong>. You\u2019ll get something that looks like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-2176\" src=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.38.12-PM-1.png?resize=294%2C213\" sizes=\"auto, (max-width: 294px) 100vw, 294px\" srcset=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.38.12-PM-1.png?w=510&amp;ssl=1 510w, https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.38.12-PM-1.png?resize=300%2C218&amp;ssl=1 300w\" alt=\"\" width=\"294\" height=\"213\" data-attachment-id=\"2176\" data-permalink=\"https:\/\/digitallearning.middcreate.net\/tips\/deleting-tweets-non-techie-starts-her-personal-information-environmentalism-journey-with-lots-of-help\/attachment\/screen-shot-2017-11-07-at-8-38-12-pm-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.38.12-PM-1.png?fit=510%2C370&amp;ssl=1\" data-orig-size=\"510,370\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screen Shot 2017-11-07 at 8.38.12 PM\" data-image-description=\"\" data-medium-file=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.38.12-PM-1.png?fit=300%2C218&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/digitallearning.middcreate.net\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-07-at-8.38.12-PM-1.png?fit=510%2C370&amp;ssl=1\" data-recalc-dims=\"1\" \/><\/p>\n<p>The directory is under the <b>Where:<\/b> section. After Macintosh HD is where our directory path begins: \/users\/myusername\/downloads\/twitterarchive<\/p>\n<p>Ok, now that we\u2019ve told Tweepy\/Twitter API where the file is, we can start querying the file for certain tweets and then telling Tweepy\/Twitter API to delete them.<\/p>\n<p><strong><span class=\"lts_dropcap  \">5)<\/span> Deleting!<\/strong> Our next move is to tell Tweepy\/Twitter what to delete. My goal was to delete all tweets that happened before January 2016. I joined Twitter in 2008, so that meant deleting tweets between 2008 and 2015. Here is the script I used:<\/p>\n<p>tweets_marked = []<\/p>\n<p>month_list = [\u20182014-01\u2019, \u20182014-02\u2019, \u20182014-03\u2019, \u20182014-04\u2019, \u20182014-05\u2019, \u20182014-06\u2019 \u20182014-07\u2019, \u20182014-09\u2019, \u20182014-10\u2019, \u20182014-11\u2019, \u20182014-12\u2019, \u20182015-01\u2019, \u20182015-02\u2019, \u20182015-03\u2019, \u20182015-04\u2019, \u20182015-05\u2019, \u20182015-06\u2019, \u20182015-07\u2019, \u20182015-08\u2019, \u20182015-09\u2019, \u20182015-10\u2019, \u20182015-11\u2019, \u20182015-12\u2019]<\/p>\n<p>for tweet in tweets:<\/p>\n<p>if tweet[3][0:7] in month_list:<\/p>\n<p>tweets_marked.append(tweet)<\/p>\n<p>&nbsp;<\/p>\n<p>I marked tweets for two years at a time, so the script above is what I used to identify the tweets between 2014-2015. To do a different set of years, just change the years in the script.<\/p>\n<p>Before I deleted, I checked to make sure I was deleting the correct tweets. This script gave me a chance to review all tweets that were marked for deletion:<\/p>\n<p>print(len(tweets_marked), \u2018tweets marked for deletion.\u2019)<\/p>\n<p>for tweet in tweets_marked:<\/p>\n<p>print(tweet[5])<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Note:<\/strong> You have to press Enter twice before all of the tweets will show up. Weird thing.<\/p>\n<p>Once I decided I was ready to delete the tweets, I copy\/pasted this script from my code editor file:<\/p>\n<p># build list of marked status IDs<\/p>\n<p>to_delete_ids = []<\/p>\n<p>delete_count = 0<\/p>\n<p>for tweet in tweets_marked:<\/p>\n<p>to_delete_ids.append(tweet[0])<\/p>\n<p>&nbsp;<\/p>\n<p># delete marked tweets by status ID<\/p>\n<p>for status_id in to_delete_ids:<\/p>\n<p>try:<\/p>\n<p>api.destroy_status(status_id)<\/p>\n<p>print(status_id, \u2018deleted!\u2019)<\/p>\n<p>delete_count += 1<\/p>\n<p>except:<\/p>\n<p>print(status_id, \u2018could not be deleted.\u2019)<\/p>\n<p>Press <strong>Enter<\/strong> twice and the deletion begins. It\u2019s a thing of beauty. You can get a count of how many tweets were deleted through that process by inputting this code:<\/p>\n<p>print(delete_count, \u2018tweets deleted.\u2019)<\/p>\n<p>After the deletion process is finished, you can re-run the scripts with other time variables (<a href=\"https:\/\/pushpullfork.com\/i-deleted-tweets\/\">or check out Kris\u2019 alternative options for marking certain tweets for deletion<\/a>).<\/p>\n<p>Through this process, I deleted 7,233 old tweets (all tweets before 2016). I\u2019m hoping to run a similar process to delete old Direct Messages from Twitter.<\/p>\n<p>Are you ready to try it? If you tried it, how did your tweet purge go? Where did you run into issues and how did you resolve them? Share your experiences in the comments section below!<\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>[This is a re-post from our old Digital Learning blog, which is now defunct. No changes were made&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1440,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1439","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology-2","content-wrap"],"_links":{"self":[{"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/posts\/1439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/comments?post=1439"}],"version-history":[{"count":1,"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/posts\/1439\/revisions"}],"predecessor-version":[{"id":1441,"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/posts\/1439\/revisions\/1441"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/media\/1440"}],"wp:attachment":[{"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/media?parent=1439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/categories?post=1439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redpincushion.us\/blog\/wp-json\/wp\/v2\/tags?post=1439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}