Created
May 27, 2014 23:50
-
-
Save rantler/1ce0895f2039ae688679 to your computer and use it in GitHub Desktop.
Read CSV skipping crap at the start of the file
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
require 'rubygems' | |
require 'csv' | |
File.open('/tmp/foo.csv', 'r') do |file| | |
file.readline # crap | |
file.readline # krap | |
csv = CSV.new(file, headers: :first_row).each do |row| | |
puts row.inspect | |
end | |
end | |
# cat /tmp/foo.csv | |
# crap | |
# karp | |
# 'a', 'b', 'c' | |
# 1, 2, 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment