Create a gist now

Instantly share code, notes, and snippets.

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