Sha256: a07382ca3bb7d9057f1bd6dc2dfd99a1d4ff2c92025e6f927af9e2e74d216fe2
Contents?: true
Size: 626 Bytes
Versions: 6
Compression:
Stored size: 626 Bytes
Contents
#!/usr/bin/env ruby -rubygems require File.dirname(__FILE__) + '/authentication' require "csv" # faster_csv (ruby 1.9) lines = CSV.read(File.dirname(__FILE__) + '/guidebooks.csv') # Exported an Excel file as CSV lines.slice!(0) # remove header line collection = StorageRoom::Collection.find('4dda7761b65245fde100005d') Guidebook = collection.entry_class lines.each do |row| guidebook = Guidebook.new(:title => row[0], :price => row[1].to_f) if guidebook.save puts "Guidebook saved: #{guidebook.title}, #{guidebook.price}" else puts "Guidebook could not be saved: #{guidebook.errors.join(', ')}" end end
Version data entries
6 entries across 6 versions & 1 rubygems