Skip to content

Instantly share code, notes, and snippets.

@milesgrimshaw
Last active December 19, 2015 18:09
Show Gist options
  • Save milesgrimshaw/5996636 to your computer and use it in GitHub Desktop.
Save milesgrimshaw/5996636 to your computer and use it in GitHub Desktop.
Merge JSON files of personal gmail header data and save as single CSV.
## MILES GRIMSHAW
require 'mechanize'
require 'csv'
require 'open-uri'
require "pp"
require "json"
CSV.open("immersion.csv", "wb") do |csv|
csv << ["Text","Date"]
for i in 0..5
file = JSON.parse(File.read("#{i}.json"))
len = file.length
for y in 0..(len-1)
text = file[y][1]
# pp text
date = text.split("Date:")[1]
if (date!=nil)
date = date.split("\r\n")[0]
if (date!=nil)
csv << [text, date]
end
end
end
## End loop through files
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment