Skip to content

Instantly share code, notes, and snippets.

@JEG2
Created March 6, 2014 19:30
Show Gist options
  • Save JEG2/9397561 to your computer and use it in GitHub Desktop.
Save JEG2/9397561 to your computer and use it in GitHub Desktop.
An example of parsing CSV-like data using | characters as separators and keeping header support
headers = nil
File.foreach(path) do |line|
fields = line.split(“|”)
if headers
row = headers.zip(fields)
# …
else
headers = fields
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment