Using Ruby, how would I automatically avoid single and double quotes in some variables written to the output file. Based on PHP, I'm looking for a function like addlashes, but for Ruby, this does not seem like a simple solution.
require "csv" def generate_array( file ) File.open("#{file}" + "_output.txt", 'w') do |output| CSV.foreach(file) do |img, _, part, focus, country, loc, lat, lon, desc, link| output.puts("[#{lat}, #{lon}, '#{img.downcase}', '#{part}', '#{loc}', '#{focus}', '#{country}', '#{desc}', '#{link}'],") end end end ARGV.each do |file| generate_array(file) end
source share