Skip to content

Instantly share code, notes, and snippets.

@kirel
Created September 20, 2015 16:44
Show Gist options
  • Save kirel/9eff6b70ef01d0447605 to your computer and use it in GitHub Desktop.
Save kirel/9eff6b70ef01d0447605 to your computer and use it in GitHub Desktop.
require 'json'
require 'csv'
require 'time'
merged = Dir.glob('Suchanfragen/Suchanfragen/*').collect { |f| JSON.load(open(f)) }.inject do |m, h|
m['event'].concat h['event']
m
end
queries = merged['event'].map {|h| [Time.at(h['query']['id'].first['timestamp_usec'].to_f/1000000).iso8601, h['query']['query_text']]}
CSV.open("queries.csv", "w") do |csv|
csv << ["time", "query"]
queries.each do |q|
csv << q
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment