Skip to content

Instantly share code, notes, and snippets.

@tfitch
Created July 8, 2014 22:32
Show Gist options
  • Save tfitch/a2513a3347f8f3b693bc to your computer and use it in GitHub Desktop.
Save tfitch/a2513a3347f8f3b693bc to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
LOG_FILE = 'access.log'
csv_data = 'method,uri\n'
File.open(LOG_FILE, 'r') do |f|
counter = 1
f.each_line do |line|
csv_data += "#{line.slice(line.index('"')+1..-1).split('"')[0].split[0]},#{line.slice(line.index('"')+1..-1).split('"')[0].split[1]}\n"
counter += 1
end
puts counter
end
File.write('access.csv', csv_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment