Collect and save daily Twitter data from Wales using Twitter's Academic API.
Project description
Tweet Suite
This package, when run, will execute a query every day that collects all tweets from Wales for the past 7 days (if running for the first time), or since the last tweet collected. It uses Twitter's V2 API.
When run it will set up an SQLite3 database in the location specified to the main script which saves tweets, their basic information and their sentiment scores from the VADER sentiment algorithm in a table called tweets
.
A table called places
then saves the geo expansion information requested in the query.
Finally, a table called matchedplaces
saves the result of each place matched to a Welsh local authority using an algorithm defined in the tweets/geo.py
file.
Authors
This package was written by ninadicara, altanner, and leriomaggio.
Good to know
API Tokens
This uses the academic API, so you need an approved account with a bearer token.
If you'd like this to work out the box then you'll need to set
the bearer token as an environment variable called SEARCHTWEETS_BEARER_TOKEN
.
Query
Currently the query returns tweets with basic information and requests the geo expansion.
If you change the query you'll also need to edit the SQL tables and data entry functions.
These are in tweets/database.py
, called create_tweets_tables()
and add_tweet_json()
.
Database
The database is SQLite3, for ease and as an alternative to CSV.
The schema for the database can be seen in the setup functions as part of the Database
class in tweets/database.py
.
There is a foreign key between place_id
in the tweets
and matchedplaces
tables that link to the primary id
entry in the places
table.
Data statement
Source: Office for National Statistics licensed under the Open Government Licence v.3.0.
Contains OS data © Crown copyright and database right 2019.
This package uses boundary data of Welsh Local Authorities (see utils/la_keys.geojson
).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tweet_suite-1.1.4.tar.gz
.
File metadata
- Download URL: tweet_suite-1.1.4.tar.gz
- Upload date:
- Size: 621.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.4 pkginfo/1.6.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2912216fa6d7829caabb5ea1c8c4627b83b12b83b46c7eeb03edd1cb1402a10 |
|
MD5 | 5ed2eb6696d04a663457ff86a1cbed57 |
|
BLAKE2b-256 | ad7a4f736d8c6ca7145494a619622d7545ac5f078e60d202657738fdbdae7bce |
File details
Details for the file tweet_suite-1.1.4-py3-none-any.whl
.
File metadata
- Download URL: tweet_suite-1.1.4-py3-none-any.whl
- Upload date:
- Size: 622.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.4 pkginfo/1.6.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8de5fb953d1c88ef23c81b51574fcd70c5c6562378418932448774edf1a95f28 |
|
MD5 | 8775d5326ea80be5e16cd9d87023a008 |
|
BLAKE2b-256 | 1e6fb559d2be6579c564508def124bb005d41517eb1a47ac12b32dc570dba5c1 |