Sha256: 74b2361f3d734a39793c75ab4cd544397a4efa7b991771ec22323dd1b456f731
Contents?: true
Size: 622 Bytes
Versions: 2
Compression:
Stored size: 622 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('4ddaf68b4d085d374a000003') klass = collection.entry_class lines.each do |row| guidebook = klass.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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
storage_room-0.2.1 | examples/import_csv.rb |
storage_room-0.2.0 | examples/import_csv.rb |