Created
March 13, 2012 19:50
-
-
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
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
#! 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