Skip to content

Instantly share code, notes, and snippets.

@rantler
Created May 27, 2014 23:50
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 rantler/1ce0895f2039ae688679 to your computer and use it in GitHub Desktop.
Save rantler/1ce0895f2039ae688679 to your computer and use it in GitHub Desktop.
Read CSV skipping crap at the start of the file
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