Write (and convert) csv files
This functions is absed on write.csv
allows for more options when writing data into csv-files.
The main input may be gven as R-object or read from file 'input'. Then, one can (re-)write using specified conversions.
An optional filter to select columns (column-name specified via 'filterCol') is available.
The output may be simultaneaously written to multiple formats, as specified in 'expTy',
tabulation characters may be converted to avoid accidentally split/shift text to multiple columns.
Note: Mixing '.' and ',' as comma separators via text-columns or fused text&data may cause problems lateron, though.
writeCsv( input, inPutFi = NULL, expTy = c("Eur", "US"), imporTy = "Eur", filename = NULL, quote = FALSE, filterCol = NULL, replMatr = NULL, returnOut = FALSE, SYLKprevent = TRUE, digits = 22, silent = FALSE, debug = FALSE, callFrom = NULL )
input |
either matrix or data.frame |
inPutFi |
(character or |
expTy |
(character) 'US' and/or 'Eur' for sparator and decimal type in output |
imporTy |
(character) default 'Eur' (otherwise set to 'US') |
filename |
(character) optional new file name(s) |
quote |
(logical) will be passed to |
filterCol |
(integer or character) optionally, to export only the columns specified here |
replMatr |
optional, matrix (1st line:search, 2nd li:use for replacing) indicating which characters need to be replaced ) |
returnOut |
(logical) return output as object |
SYLKprevent |
(logical) prevent difficulty when opening file via Excel. In some cases Excel presumes (by error) the SYLK format and produces an error when trying to open files : To prevent this, if necessary, the 1st column-name will be changed from 'ID' to 'Id'. |
digits |
(interger) limit number of signif digits in output (ie file) |
silent |
(logical) suppress messages |
debug |
(logical) for bug-tracking: more/enhanced messages |
callFrom |
(character) allow easier tracking of message(s) produced |
writes file to disk and returns NULL
unless returnOut=TRUE
write.csv
in write.table
, batch reading using this package readCsvBatch
dat1 <- data.frame(ini=letters[1:5],x1=1:5,x2=11:15,t1=c("10,10","20.20","11,11","21,21","33.33"), t2=c("10,11","20.21","kl;kl","az,az","ze.ze")) fiNa <- file.path(tempdir(),paste("test",1:2,".csv",sep="")) writeCsv(dat1,filename=fiNa[1]) dir(path=tempdir(),pattern="cs") (writeCsv(dat1,replM=rbind(bad=c(";",","),replBy="__"),expTy=c("Eur"), returnOut=TRUE,filename=fiNa[2]))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.