I'm building a simple web application using Sinatra.
I have an external text file and would like to parse it using CSV. Then I would like to export the data and create a database using DataMapper. I'm stuck on how to accomplish this.
This is what I have so far:
require 'sinatra'
require 'csv'
require 'data_mapper'
CSV.foreach("words.txt") do |row|
puts row[0]
end
DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/scrabble.db")
class Letters
include DataMapper::Resource
property :id, Serial
property :content, Text, :required => true
property :created_at, DateTime
property :updated_at, DateTime
end
Can anyone point me to the right direction?
if you itterate through a list of words, you need to do like that: