2017-01-28 1 views
0

트위터 아카이브와 마찬가지로 CSV 파일을 포맷하는 방법을 알고 싶습니다. R에 문제가 없으므로 해결책이 없습니다.). Twitter 아카이브는 사용자 타임 라인이며 내 CSV (R을 사용하여 정서 분석을 수행 할 것입니다)는 짹짹이 포함 된 검색 결과입니다. 트위터 아카이브의트위터 아카이브와 똑같은 형식 트위터 R

샘플

"tweet_id","in_reply_to_status_id","in_reply_to_user_id","timestamp","source","text","retweeted_status_id","retweeted_status_user_id","retweeted_status_timestamp","expanded_urls" 
"81423594213695488","","","2016-12-29 14:18:08 +0000","<a href=""http://twitter.com/download/android"" rel=""nofollow"">Twitter for Android</a>","RT @SwiftOnSecurity: We're going to tell kids that laptops used to store data on tiny mirrors spinning @ 7200rpm and they're going to think…","814187405175570432","2436389418","2016-12-28 19:12:58 +0000","" 
"876926582348550143","","","2016-12-22 13:29:16 +0000","<a href=""http://twitter.com/download/android"" rel=""nofollow"">Twitter for Android</a>","RT @MKBHD: Shout-out to everyone going home and becoming family tech support for the holidays","811910809521680384","29873662","2016-12-22 12:26:36 +0000","" 

나는하기 위해 관리했습니다 무엇 지금까지

"text" 
b'RT @notCORYGREGORY: when hillary uses a private email server asking how to print recipes vs when trump takes healthcare from 20+ million am\xe2\x80\xa6' 
b'RT @Salon: Germany is giving up on President Trump' 

내가 파이썬에서 그것을 할 방법 :

csvFile = open('tweets.csv', 'a') 
csvWriter = csv.writer(csvFile, delimiter=',') 

for tweet in tweepy.Cursor(api.search, 
    q="trump", 
    rpp=100, 
    result_type="recent", 
    include_entities=True, 
    lang="en").items(5): 
     print (tweet.text) 
     csvWriter.writerow([tweet.text.encode('utf-8')]) 

csvFile.close() 

나는 열려있어 솔루션에 R

+1

R에는 twitteR이라는 트윗을 다운로드 할 수있는 패키지가 있습니다. 거기에서 날짜와 언어에 따라 트윗을 다운로드하고 나중에 csv로 쓸 수도 있습니다. –

답변

0

I 당신의 질문을 완전히 이해하지는 못했지만 R의 twitteR 라이브러리, 특히 "twListToDF"함수를 살펴보고 싶을 수도 있습니다. write.csv와 결합하면 R이 읽을 수있는 CSV 형식으로 수집 한 트윗을 바로 올릴 수 있습니다.

write.csv(twListToDF(your_tweets), file="your_tweets.csv")