Creating a comma seperated csv file in ruby -
I have such an array reference
a1 = [["http: // ww When I write it in CSV file it is written as ["http: />> IAM). / O.amazon.com "] [" unsuccessful "]
but I want to write
http: / /ww.amazon.com failed
Firstly you will see the array a1
b1 = a1.flatten # => ["http: //wwamazon.com", "unsuccessful"] Then you need the following csv variable:
each line (array) 'csv' csv_string = CSV.generate ({: col_sep = & gt; \ T "}) do | csv | CSV & lt; : col_sep = & gt;" \ t " one per line Inserting tab separator
Change the value of : col_sep = & gt; Finally you have the correct form of csv in
csv_string Is
Comments
Post a Comment