Skip to content

Instantly share code, notes, and snippets.

@bradland
Created January 27, 2012 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradland/1689330 to your computer and use it in GitHub Desktop.
Save bradland/1689330 to your computer and use it in GitHub Desktop.
Analyze TSV log
#!/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