Skip to content

Instantly share code, notes, and snippets.

@sk22
Last active June 19, 2020 00:10
Show Gist options
  • Save sk22/eff7868c5d6dd053fd5501821a7fd54c to your computer and use it in GitHub Desktop.
Save sk22/eff7868c5d6dd053fd5501821a7fd54c to your computer and use it in GitHub Desktop.
Count tweets per day
#!/usr/bin/env node
// download: https://twitter.com/settings/your_twitter_data/data
// run in twitter-archive/data/
window = {}
window.YTD = {}
window.YTD.tweet = {}
require('./tweet.js')
require('fs').writeFileSync('tweets.csv',
window.YTD.tweet.part0
.map(t => ({ text: t.tweet.full_text, date: new Date(t.tweet.created_at) }))
.map(({ text, date }) => `${text}\t${date.toISOString().split('T')[0]}\t${date.toISOString().split('T')[1].slice(0, 5)}`)
.join('\n').toString())
#!/bin/bash
# requires https://harelba.github.io/q/
q -t 'SELECT c2, count(*) FROM ./tweets.csv WHERE c2 IS NOT NULL GROUP BY c2' > tweets-by-date.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment