-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateDataService.py
More file actions
39 lines (32 loc) · 1.21 KB
/
CreateDataService.py
File metadata and controls
39 lines (32 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import twin_nl as TweetService
import csv
def createData(start_date, end_date, nr,source):
# regular_tweets = TweetService.get_tweets(
# start_date,
# end_date,
# nr,
# 'een,het,de'
# )
bitcoin_tweets = TweetService.get_tweets(
start_date,
end_date,
nr,
'bitcoin'
)
# _writeTweetSourceToCsv('data/'+source+'/regular-tweets.csv', regular_tweets)
_writeTweetSourceToCsv('data/'+source+'/bitcoin-tweets.csv', bitcoin_tweets)
def createBitcoinData(btc_dataframe, source):
btc_dataframe.to_csv('data/'+source+'/bitcoin-values.csv')
def _writeTweetSourceToCsv(file_name, tweets):
with open(file_name, 'w', encoding="utf-8") as file:
writer = csv.writer(file)
for tweet in tweets:
print(tweet)
writer.writerow(
[tweet['date'], tweet['content'][0], tweet['author']])
def writeDayScoreToCSV(file_name, source, days):
file_source = 'data/'+source+'/'+file_name
with open(file_source, 'w', encoding="utf-8") as file:
writer = csv.writer(file)
for day in days:
writer.writerow([day['date'], day['sentiment']['positive'], day['sentiment']['negative']])