Created
January 27, 2012 15:37
-
-
Save bradland/1689330 to your computer and use it in GitHub Desktop.
Analyze TSV log
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
#!/usr/bin/env ruby -wKU | |
class DataAnalyzer | |
def initialize | |
# Check for Ruby 1.9 | |
unless RUBY_VERSION.scan('1.9').length > 0 | |
puts "This script reqires Ruby 1.9 (specifically, ordered hashes). Sorry! Check out RVM or rbenv for easy management of Ruby versions." | |
exit 1 | |
end | |
# We must have at least one file to process | |
if ARGV.length < 1 | |
STDERR.puts "This script expects at least one argument" | |
exit 1 | |
end | |
# Get data file path | |
@file = File.expand_path(ARGV[0]) | |
end | |
def start | |
File.open(@file, 'r') do |file| | |
file.each_line do |line| | |
f = line.split(/\t/) | |
puts "#{f[0]} (#{f[1]}): #{f[2].to_f}" | |
end | |
end | |
end | |
end | |
DataAnalyzer.new.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment