Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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