Skip to content

Instantly share code, notes, and snippets.

@jrsconfitto
Created March 13, 2012 19:50
Show Gist options
  • Save jrsconfitto/2031139 to your computer and use it in GitHub Desktop.
Save jrsconfitto/2031139 to your computer and use it in GitHub Desktop.
Will count the number of tab delimited fields in the passed file name
#! ruby
if ARGV.length == 1
if File.exists?(ARGV[0])
file = File.open(ARGV[0], "r")
puts "File name: #{ARGV[0]}"
count = 1
file.each do |line|
line_count = line.split("\t").count
if line_count != 23
puts "Line: #{count} has #{line_count} fields. Fix it!"
end
count += 1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment