Download dataset.py from JoanWaweru/Code-SwitchedSentimentAnalysis: direct link, hf CLI and curl.
- Browser
- Download file 441 Bytes
-
https://huggingface.co/JoanWaweru/Code-SwitchedSentimentAnalysis/resolve/main/dataset.py
- Command line
-
hf download hf://JoanWaweru/Code-SwitchedSentimentAnalysis/dataset.py
-
curl -L -o dataset.py https://huggingface.co/JoanWaweru/Code-SwitchedSentimentAnalysis/resolve/main/dataset.py
441 Bytes
| import snscrape.modules.twitter as sntwitter | |
| import pandas as pd | |
| query = "(@Safaricom_Care) until:2022-10-24" | |
| tweets = [] | |
| limits = 5000 | |
| for tweet in sntwitter.TwitterSearchScraper(query).get_items(): | |
| #print(vars(tweet)) | |
| #break | |
| if len(tweets) == limits: | |
| break | |
| else: | |
| tweets.append([tweet.date, tweet.user.username,tweet.content]) | |
| df = pd.DataFrame(tweets, columns=['Date', 'User', 'Tweet']) | |
| df.to_csv('safaricomDataset.csv') | |