https://github.com/softplus/twitter_export
Some scripts to work with the Twitter data export files
https://github.com/softplus/twitter_export
twitter twitter-api
Last synced: 12 months ago
JSON representation
Some scripts to work with the Twitter data export files
- Host: GitHub
- URL: https://github.com/softplus/twitter_export
- Owner: softplus
- License: mit
- Created: 2023-01-03T18:26:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-03T19:59:20.000Z (over 3 years ago)
- Last Synced: 2025-02-15T08:15:49.367Z (about 1 year ago)
- Topics: twitter, twitter-api
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# twitter_export
Takes your Twitter export file and turns it into CSV files.
Everyone loves CSV files.
MIT license (see file LICENSE).
(c) 2023 John Mueller / johnmu.com
## Setup
```bash
# get repo
git clone https://github.com/softplus/twitter_export
cd twitter_export
# setup python stuff, virtualenv -- recommended
virtualenv .venv && source .venv/bin/activate
pip install -r requirements.txt
# ... run things now ...
# ... when done ...
deactivate
```
## Setup
### Twitter API setup
1. Make a copy of `_settings_sample.py` and call it `_settings.py`
2. Follow the guide at https://python-twitter.readthedocs.io/en/latest/getting_started.html to create a new Twitter app, and to get your tokens.
3. When creating an app, you can use any URL.
4. Copy `API Key`, `API Key Secret`, and `Bearer Token` into the appropriate fields in `_settings.py`
That's all. I think
### Twitter archive
Extract your Twitter archive and place it in the `twitter` folder here.
This folder should include sub-directories for `assets` and `data`.
## Usage
```bash
source .venv/bin/activate
# ...
# read all your own tweets, store Q&A as CSV in files in /output/
python3 json_to_csv.py
# compile threads where you reply to your own tweets
python3 csv_to_threads.py
# create Q&A CSV file to feed your NLG
# This takes a long time, it fetches the tweets you replied to via Twitter API.
# Note: you must set up the Twitter API first.
# Tweepy will pause when your API quota needs it.
python3 csv_to_qa.py
# that's all folks
deactivate
```
## Dependencies
Some of the code uses `tweepy` to access the Twitter API.
## todos
* compile popular threads to drop onto blog
* export all tweets to csv
* export all posts with images
* stats on tweets/month, tweets/daytime, time-to-reply
## Questions?
Drop me a post at https://johnmu.com/+