REBOL [
Title: "CSV"
Date: 3-Jul-2002
Name: CSV
Version: 1.0.0
File: %CSV.r
Author: "Andrew Martin"
Purpose: ".CSV file manipulation functions."
Email: Al.Bri@xtra.co.nz
Web: http://valley.150m.com
Category: [db util 1]
Example: [
write %Test.csv Mold-CSV [
["Column One" "Column Two" "Total Column"]
[1 2 3]
[2 3 5]
[3 4 7]
]
read %Test.csv
delete %Test.csv
]
]
Mold-CSV: function [
"Molds an array of values into a CSV formatted string."
Array [block!]
] [Page Line] [
Page: make block! length? Array
Line: clear ""
foreach Row Array [
foreach Item Row [
if not none? :Item [
insert tail Line join either string?
:Item [mold Item] [:Item] #","
]
]
remove back tail Line
append Line newline
append Page copy Line
clear Line
]
rejoin Page
]