Magical Kingdom of CSV Wonder

Since working with CSV files (comma separated values) is so common, Ruby has a whole library of methods designed just for that purpose.

Require the csv library at the top of your file to get access to this magical kingdom of wonder:

require “csv”

Then you can call built-in methods, instead of rolling your own. Here’s one that iterates over each item in a csv file:

CSV.foreach(filename, some_optional_stuff)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Skip to content