Skip to content

Instantly share code, notes, and snippets.

@flakyfilibuster
Created October 18, 2012 07:54
Show Gist options
  • Save flakyfilibuster/3910342 to your computer and use it in GitHub Desktop.
Save flakyfilibuster/3910342 to your computer and use it in GitHub Desktop.
CSV methods for easy csv to array and array to csv conversion
Peggie Bernier (598)-885-3990 [email protected]
Ines Roberts (717)-629-5254 [email protected]
Carley Luettgen (153)-754-3308 [email protected]
Evie Bashirian (684)-662-7552 [email protected]
peggie bernier (598)885-3990 [email protected]
ines roberts 717.629.5254 [email protected]
carley Luettgen 153.754.3308 [email protected]
Evie Bashirian 684.662.7552 [email protected]
require 'csv'
def array_to_csv(output_file_name, array)
CSV.open(output_file_name,'w') do |csv|
array.each {|line| csv << line}
end
end
def csv_to_array(file_name)
array = []
CSV.foreach(file_name) {|line| array << line}
array
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment