Skip to content

Instantly share code, notes, and snippets.

@apricoton
Last active May 20, 2016 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apricoton/a33f962b3cf1c66003727a48b6d2c6b5 to your computer and use it in GitHub Desktop.
Save apricoton/a33f962b3cf1c66003727a48b6d2c6b5 to your computer and use it in GitHub Desktop.
Twitterの「全ツイート履歴」に入っている月別JavaScriptファイルから1つのJSONを作るスクリプト
var fs = require('fs'),
path = require('path');
var output_filename = 'tweets.json';
var js_dir = path.join('data', 'js', 'tweets');
var Grailbird = {
data: {},
};
fs.readdirSync(js_dir).forEach(function (file) {
var filepath = path.join(js_dir, file);
console.log('reading : ' + filepath);
var data = fs.readFileSync(filepath, 'utf8');
eval(data);
});
var tweets = [];
Object.keys(Grailbird.data).forEach(function (key) {
console.log('processing : ' + key);
tweets = tweets.concat(Grailbird.data[key]);
});
console.log('convert to json');
fs.writeFileSync(output_filename, JSON.stringify(tweets), 'utf8');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment