Created
July 8, 2014 22:32
-
-
Save tfitch/a2513a3347f8f3b693bc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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