Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

read headers of csv using ruby

headers = CSV.open('file.csv', 'r') { |csv| csv.first }
Comment

PREVIOUS NEXT
Code Example
Ruby :: rails debug 
Ruby :: text_field_tag placeholder rails 
Ruby :: ruby class variable 
Ruby :: ActionController::InvalidAuthenticityToken rails when submitting form 
Ruby :: string to hash ruby 
Ruby :: Rails is not defined 
Ruby :: selenium webdriver get attribute ruby 
Ruby :: rails server not updating 
Ruby :: ruby on rails scaffold generator example with belongs to relationship 
Ruby :: string ruby 
Ruby :: ruby reduce hash 
Ruby :: ruby array of strings 
Ruby :: ruby get min value from array 
Ruby :: formatting a floating point number in ruby 
Ruby :: rails humanize date 
Ruby :: ruby prepend string 
Ruby :: rails change reference 
Ruby :: add several columns rails 
Ruby :: ruby array serach 
Ruby :: Ruby deep clone with Marshal 
Ruby :: ruby on rails db column contains string 
Ruby :: In Jekyll - get the parent url path of a collection 
Ruby :: redis localhost url 
R :: r convert string to list of characters 
R :: read csv in r 
R :: name elements in vector r 
R :: how to return the date with only the day in it in r 
R :: r: rename a column 
R :: R for loop append to vector 
R :: how to link world bank data into r 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =