Skip to content

Instantly share code, notes, and snippets.

@llaskin
Created January 4, 2012 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save llaskin/1560250 to your computer and use it in GitHub Desktop.
Save llaskin/1560250 to your computer and use it in GitHub Desktop.
my_arr = ["colA, colB, colC, colD, colE, colF", "val1,val2,val3,val4,val5,val6","val7,val8,val9,val10,val11,val12"]
require 'csv'
CSV.open("myfile.csv", "w") do |csv|
csv << my_arr[0] #The label row which labels each column
my_arr.drop(1)
my_arr.each{|string|
csv << string
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment