8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

自分の全ツイートデータから使用したクライアントの集計

Posted at

背景

2015/2/18現在、Twitterを利用して約5年が経過しました。
最初はガラケーで初めて、その後はiPhoneだったりWindowsだったりMacだったり色んな環境でTwitterを利用しています。

その中で様々なクライアントを使用しています。
そこで

  • どのアプリを
  • どれくらい使ったか

が知りたくなったのでRubyを使って調べました。

全ツイートのダウンロード

この辺を参考にしてください。

コード

ダウンロードして解凍したファイル(ここではTweetDataと名前を変えました)を以下のsource_count.rbと同じディレクトリに置きます。

source_count.rb
require 'csv'

# 新しいハッシュの生成
via_count = Hash.new

# ファイルの読み込み
reader = CSV.open('TweetData/tweets.csv','r')

# CSVファイルの中でsourceのデータが入ってるのは4番目
source_clonum = 4
# CSVファイルの中でツイートのデータが入ってるのは5番目
tweet_clonum = 5
# RTを除いた全ツイート数
total = 0

# 先頭行は不要だから飛ばす
reader.take 1

# 1ツイートずつ読み込み
reader.each do |row|
  # RTを除く
  if !row[tweet_clonum].index('RT')
    # ツイートのsourceの左端の'>'を検索
    pos_left = row[source_clonum].index('>')
    # ツイートのsourceの右端の'<'を検索
    pos_right = row[source_clonum].rindex('<')
    
    # ツイートのsource部分のみ取り出し
    source = row[source_clonum][pos_left+1..pos_right-1]
    
    # ハッシュの中に既にsourceのデータはあるか?
    if via_count.key?(source)
      # データがあったら1つ増やす
      new_count = via_count[source].to_i + 1
      via_count.store(source,new_count)
    else
      # なかったら1にする
      via_count.store(source, 1)
    end
    
    # RTを除いた全ツイート数をカウント
    total = total + 1
  end
end

# 結果を表示(降順)
via_count.sort_by{|key,val| -val}.each {|key, val|
  # keyの値の割合を計算
  val_rate = (val / total.to_f) * 100
  puts "#{key}:#{val}(#{sprintf("%.3f", val_rate)}%)"
}
puts "total:#{total}"

解説

ダウンロードしたツイートのデータの形式はCSVです。
以下の順番に情報(?)が格納されてます。

"tweet_id","in_reply_to_status_id","in_reply_to_user_id","timestamp","source","text",…(略)

その中のsourceは以下の様になっています。

"<a href=""http://twitter.com"" rel=""nofollow"">Twitter Web Client</a>"

この場合、"Twitter Web Client"の前後のアンカータグがいらないので、
アンカータグの中の部分(?)のみを取り出します

# ツイートのsourceの左端の'>'を検索
pos_left = row[source_clonum].index('>')
# ツイートのsourceの右端の'<'を検索
pos_right = row[source_clonum].rindex('<')

# ツイートのsource部分のみ取り出し
source = row[source_clonum][pos_left+1..pos_right-1]

結果

自分は以下のようになりました。(見辛い…)

Janetter for Mac:15850(17.912%)
Janetter:13884(15.690%)
Echofon:11935(13.488%)
Tween:7972(9.009%)
Twitter for Websites:6789(7.672%)
TweetMe for iPhone:4444(5.022%)
Hatena:3401(3.843%)
Twitter:3103(3.507%)
Apple信者の会我孫子支部:2068(2.337%)
feather for iOS:1911(2.160%)
TweetList!:1658(1.874%)
Ask.fm:1385(1.565%)
Twitter Web Client:1344(1.519%)
ついっぷる :1299(1.468%)
Foursquare:1260(1.424%)
twittbot.net:1243(1.405%)
iOS:1082(1.223%)
Tweetbot for iOS:963(1.088%)
Hel1um Pro on iOS:839(0.948%)
Tweet-this-page:836(0.945%)
音ノ木坂学院_アイドル研究部:767(0.867%)
SOICHA:635(0.718%)
Tabtter Free:533(0.602%)
TwitRocker:416(0.470%)
TwitBird:294(0.332%)
トルネ:222(0.251%)
twicca:206(0.233%)
TweetDeck:187(0.211%)
Twit for Windows:170(0.192%)
Ustream.TV:156(0.176%)
ついっぷる for iPad:153(0.173%)
Mobile Web:152(0.172%)
2ch matome viewer NONOwa on iOS:131(0.148%)
wiwit live:118(0.133%)
Safari on iOS:102(0.115%)
ニコニコ生放送:97(0.110%)
Tweet ATOK:88(0.099%)
Paper.li:84(0.095%)
MobileRSS:77(0.087%)
OS X:72(0.081%)
TwitBird iPad:70(0.079%)
ニコニコ動画:51(0.058%)
Twitter for iPhone:46(0.052%)
Photos on iOS:44(0.050%)
erased_102163:40(0.045%)
YoruFukurou:36(0.041%)
Keitai Web:34(0.038%)
Tweetbot for iΟS:33(0.037%)
iconDecotter :22(0.025%)
FC2 Blog Notify:21(0.024%)
あにみた!:14(0.016%)
Twitter for iPad:13(0.015%)
Dolphin Browser:11(0.012%)
ガルシアを絶対に許さない市民の会:10(0.011%)
Togetter:9(0.010%)
Hel1um on iOS:5(0.006%)
CNET Japan:5(0.006%)
【Q&Aなう】:5(0.006%)
feedly on iOS:5(0.006%)
twimaker:4(0.005%)
ニコニコニュース:4(0.005%)
今日、誰と一緒に食べる?:4(0.005%)
OpenTween:3(0.003%)
ついっぷる for iPad:3(0.003%)
Chrowety:3(0.003%)
2014's fortune by 2013's tweets:3(0.003%)
しずかったー:3(0.003%)
うどん大陸 (Uton Tairiku):2(0.002%)
Evernote for iOS:2(0.002%)
Buffer:2(0.002%)
12180423:2(0.002%)
P3:PeraPeraPrv:2(0.002%)
PlayStation®Vita:2(0.002%)
きみの熱い球団愛と知識を試せ! 12球団クイズ魂:2(0.002%)
Teewee:2(0.002%)
Twitterrific:2(0.002%)
創造神ジェネレーター:2(0.002%)
ツイートプロファイリング:2(0.002%)
ツイセーブ:2(0.002%)
読書メーター:1(0.001%)
最高の夏ジェネレーター:1(0.001%)
シロくも powered by カメリオ3:1(0.001%)
twithitter.com:1(0.001%)
SmartNews - Trending News & S...:1(0.001%)
LinkedIn 起業シミュレーター:1(0.001%)
ハンドサイン画像ジェネレーター:1(0.001%)
Twitter for Mac:1(0.001%)
PandaCall:1(0.001%)
twinavi:1(0.001%)
野球ポジション診断:1(0.001%)
FansFans:1(0.001%)
あなたはどんな歴史キャラ? 歴キャラ診断:1(0.001%)
Tweet分析 otacheck:1(0.001%)
Maps on iOS:1(0.001%)
userchart.jp:1(0.001%)
Web書道:1(0.001%)
今日のスタンド:1(0.001%)
ダイジョーブおみくじ:1(0.001%)
Panasonic Beauty「あなたのいいね!サンタは誰?」:1(0.001%)
Chance of Rain Japan:1(0.001%)
TOKYO 2020 楽しい公約:1(0.001%)
Mobile Web (M5):1(0.001%)
Twitpic:1(0.001%)
ノイタミナ公式アプリ:1(0.001%)
ソニー ヘッドホン LOVE MUSIC キャンペーン:1(0.001%)
elemetter:1(0.001%)
twit SH:1(0.001%)
TwitThis:1(0.001%)
ツイアニ:1(0.001%)
MYCOM JOURNAL LP:1(0.001%)
平均メーター:1(0.001%)
診断ティキット:1(0.001%)
Seesmic Web:1(0.001%)
Twilk.com:1(0.001%)
Twittelator:1(0.001%)
ダ・ヴィンチ電子ナビ(WEB):1(0.001%)
心理テスト「人生において重要視しているもの」:1(0.001%)
total:88489

8
7
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?