Skip to content

Instantly share code, notes, and snippets.

@ahmad19
Created November 29, 2018 06:20
Show Gist options
  • Save ahmad19/a50c694aa670b809b965d9f2febac9bd to your computer and use it in GitHub Desktop.
Save ahmad19/a50c694aa670b809b965d9f2febac9bd to your computer and use it in GitHub Desktop.
Read CSV and return as Array of hashes
# Using ruby's inbuild CSV library
data = []
CSV.foreach(file_path, headers: true) do |row|
data << Hash[row]
end
data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment