[REBOL] Re: Creating CSV files
From: ryanc:iesco-dms at: 26-Sep-2001 10:10
Here is a function I wrote a looong time ago to export into different formats.
I can see about 25 ways to make it better now, but it at least shows you the
general idea.
--Ryan
delimit: Function
[
{Returns delimitation you specify in example.}
db [block!] "Block containing blocks of records, or just a single record
block."
example [string!] {String with x's (#"x") specifying where data goes.}
] [
rv
new-records
new-record
] [
if not block? db/1 [db: reduce [db] ]
new-records: copy ""
foreach record db [
new-record: copy example
parse new-record [
some [to "x" x: (
remove/part x 1
x: insert x first record
either not tail? next record [record: next record] [record: [""] ]
)
:x
]
]
append new-records head new-record
]
new-records
]
G. Edw. Learned
wrote:
> I have a block, and am trying to write it out to a CSV type file, with each
> element of the block a seperate value i.e.:
>
> ["a" "b" "c" "d"]
>
> being written out as:
>
> a,b,c,d
>
> I'm missing something, seems like this should be a piece of cake. Anyone
> want to bail me out?
>
> Thanks
>
> ---
> G. Edw. Learned - [learned--talentsinc--net]
> (Never apply a Star Trek Solution to a Babylon Five Problem)
> --
> To unsubscribe from this list, please send an email to
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400