Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

write csv with header ruby

headers = ['col1','col2','col3']

CSV.open(file_path, 'a+', {force_quotes: true}) do |csv|
  csv << headers if csv.count.eql? 0 # csv.count method gives number of lines in file if zero insert headers
end
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #write #csv #header #ruby
ADD COMMENT
Topic
Name
9+8 =