February 3 - Building a CSV File Generator in Pure Ruby
This coding exercise will walk through how you can build a CSV file generator that will allow you to export data that can be viewed in applications such as Microsoft Excel.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
  • Complete the Exercise
Video locked
This video is viewable to users with a Bottega Bootcamp license

Summary

Build a CSV File generator in Ruby.

Exercise Description

This coding exercise examines how to build a method that takes in a collection of data and generates a CSV file that can be viewed in applications such as Microsoft Excel.

Example Data Input

headers = %w{Name Title Email}

crm_data = [
  ["Darth Vader", "CEO", "betterthan@theforce.com"],
  ["Luke Skywalker", "Dev", "daddy@issues.com"],
  ["Kylo Ren", "COO", "daddy2@issues.com"],
]

Generated File

large

Real World Usage

Being able to generate CSV files is a common feature I'm asked to build in a wide variety of applications. Many users need the ability to export data and CSV is one of the most popular methods for reports because they can be opened in Excel.

Starter Code

Code File