Skip to content

Instantly share code, notes, and snippets.

@jdkealy
Created August 23, 2011 14:38
Show Gist options
  • Save jdkealy/1165297 to your computer and use it in GitHub Desktop.
Save jdkealy/1165297 to your computer and use it in GitHub Desktop.
#loop through tsv, add to array
f = File.open(input_file, "r")
f.each_with_index { |line, i|
name_index = ""
price_index = ""
if(i==0) then
headers = line.split("\t")
headers[2] = headers.last.strip
name_index = headers.index("Name")
price_index = headers.index("Price")
end
next if i == 0
next if line[0] == "#"
words = line.split("\t")
p = Output.new
puts name_index
p.name = words[0]
p.price = words[2].to_f
arr.push(p)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment