Created
September 20, 2015 16:44
-
-
Save kirel/9eff6b70ef01d0447605 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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