Saving Data Back to the CSV File
require 'csv'
people = CSV.read('text.txt')
laura = people.find { |person| person[0] =~ /Laura/ }
laura[0] = "Lauren Smith"
CSV.open('text.txt', 'w') do |csv|
people.each do |person|
csv << person
end
end
//File: text.txt
F,M,M,45
L,C,F,23
D,P,F,38
Related examples in the same category