Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. require "csv"
  2. require_relative "patient"
  3. patients = []
  4. csv_file = "patients.csv"
  5. csv_options = { headers: :first_row, header_converters: :symbol }
  6. CSV.foreach(csv_file, csv_options) do |row|
  7. row[:id] = row[:id].to_i # Convert column to Integer
  8. row[:cured] = row[:cured] == "true" # Convert column to boolean
  9. patients << Patient.new(row)
  10. end
  11.  
  12. p patients
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement