Loady - A CSV file loader with simple logging

Loady is a simple file reader and logger. Use it to quickly load a csv file, continue on error rows, and do basic logging.

It works with ruby 1.9.

Install

gem install loady

Use bundler. Include the gem in your Gemfile:

gem 'loady'

Use

If an error occurs, Loady will continue reading the file, ignoring problems rows and logging a warning for each.

By default, messages are logged to the standard output.

Basic usage:

Loady.csv "/your/file.csv" do |row|
  # your code to process each row goes here
  puts "#{row[0]}, #{row[1]}, etc."
end

Skip the first row and log to a file:

logger = Logger.new "/your/file.log"

Loady.csv "/your/file.csv", :logger => logger, :skip_first_row => true do |row|
  # do some stuff for each row
end

Name your attributes:

Loady.csv "/your/file.csv"  do |row|
  Monkey.create row.to_attributes [:name, :year, :mom]
end