Working with CSV files
In this example we will have a look how to read / write data to CSV file.
It is necessary to include CSV library require 'csv'
, and we can name our file as change_data.rb
:
Additionally, in CSV.open method as an option, we could also include force_quotes:true
if it is necessary.
The original example looks like:
After running change_data.rb
script, we have a filled in value “Alen” in newly created CSV file example_changed.csv
: