我目前正在进行一个项目,该项目获取Tweets并进行快速情绪分析,并将tweet ID、tweet的日期、tweet的文本和tweet的情感极性加载到MS Access表中(Office 2013)。我已经将输出转换为字符串,除了情感极性与表(Test)数据类型相匹配。我的代码是:from pattern.web import Twitter
import time
import pyodbc
from textblob import TextBlob
cnxn = pyodbc.connect(r'DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:...SentimentAnalysis.accdb;')
cursor = cnxn.cursor()
s = Twitter().stream('#testhash')
for i in range(25):
time.sleep(1)
s.update(bytes=1024)
if s:
Ident = str(s[-1].id)
TweetDate = str(s[-1].date)
TweetText = str(s[-1].text.encode('utf8'))
x = s[-1].text
blob = TextBlob(x)
sent = blob.sentiment.polarity
cursor.execute('insert into Test([Ident],[TweetDate],[TweetText],[TweetSentiment]) values (Id