Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: xplore
See also: readm readcsvm readascii read write writem

Quantlet: writecsv
Description: writes numerical and text data to a CSV file

Usage: writecsv(data,filename{,separator,deccomma,doquotes,dfmt,tfmt})
Input:
data data to write; they can be a numerical matrix, a text matrix or a list containing numerical and text vectors and matrices having all the same number of rows
filename string, contains the name of the file
separator optional string that contains the data separator sign (default is ";", which is used even if the separator is missing or an empty string)
deccomma optional scalar, indicates whether numbers should use a decimal point (zero value, default) or a decimal comma (non-zero value)
doquotes optional scalar, indicates whether strings should be checked on the occurrence of special characters such as separators or quotes; these strings are then converted (e.g., " is replaced by "") and enclosed in quotation marks as CSV format requires. Parameter doquotes is zero by default (no checking); if doquotes is non-zero, strings are transformed, but it slows down the writing process
dfmt optional format string for numerical vectors and matrices ("%g" by default)
tfmt otional format string for text vectors and matrices ("%s" by default)

Note:

Example:
library("xplore")
x = #(1,2.34,3.0,4)
t = #("Hi","test","three", "four")
file = getenv("XPL4OUTDATA") + "/" + "exwritecsv.csv"
writecsv(list(x,t), file)
r = readcsvm(file)
r

Result:
The file written to "exwritecsv.csv" contains the following
lines:

1;Hi
2.34;test
3;three
4;four

and the output window contains:

Contents of string
[1,] "readm: Found    4 line(s) and    2 column(s)"

Contents of r.type
[1,]        0
[2,]        1

Contents of r.double
[1,]        1
[2,]     2.34
[3,]        3
[4,]        4

Contents of r.text
[1,] "Hi"
[2,] "test"
[3,] "three"
[4,] "four"



Author: P. Cizek, 20020708
(C) MD*TECH Method and Data Technologies, 05.02.2006