From: charlie bowman Date: 2006-01-28T06:18:11+09:00 Subject: csv help Can anyone point me to a good tutorial on csv files and ruby. I've read the docs that go along with the standard csv library but it's hard to put it all together. I'm trying to write a simple timekeeper application using csv files but I don't really know where to start. Maybe someone can point out the many flaws in this beginners attempt. Currently all I'm trying to do is create a row of time data each time the app is ran. require 'csv' class TimeKeeper ## constant of where the csv file is stored @@csv_file = "/shared/home/cmbowma/.timeclock" def initialize end def read @data = String.new CSV.parse open(@@csv_file).read do |row| @data << row.to_s << ',' end @data end def write(data) writer = CSV.open(@@csv_file, 'w') writer << data writer.close end end csv = TimeKeeper.new @data = csv.read.to_a time = Time.now @data << [time] csv.write(@data) -- Posted via http://www.ruby-forum.com/.