Sha256: 54fec5b7839ba01fbcb0526257dedcf6eadca93fa4f141dd5818b1ad16c475c6
Contents?: true
Size: 556 Bytes
Versions: 4
Compression:
Stored size: 556 Bytes
Contents
#!/usr/bin/env ruby -rubygems require File.dirname(__FILE__) + '/authentication' require 'faster_csv' lines = FasterCSV.read(File.dirname(__FILE__) + '/guidebooks.csv') # Exported an Excel file as CSV lines.slice!(0) # remove header line klass = StorageRoom.class_for_name('Guidebook') lines.each do |row| guidebook = klass.new(:name => row[0], :price => row[1].to_f) if guidebook.save puts "Guidebook saved: #{guidebook[:name]}, #{guidebook[:price]}" else puts "Guidebook could not be saved: #{guidebook.errors.join(', ')}" end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
storage_room-0.1.3 | examples/import_csv.rb |
storage_room-0.1.2 | examples/import_csv.rb |
storage_room-0.1.1 | examples/import_csv.rb |
storage_room-0.1.0 | examples/import_csv.rb |