Skip to content
Prev 2679 / 15274 Next

How to format a CSV file output ?

Jeff Ryan <jeff.a.ryan <at> gmail.com> writes:
matrix(c(strftime(as.POSIXlt(index(x)),'%m/%d/%Y,%H:%M'),x),dimnames=list(NULL,c('','Indec')),nc=2)
Hi jeff,

Thanks for the answer.

Because I need to compare two files, I have to format the csv file.
To compare the two files I use WinMerge :
http://winmerge.org/

I have slightly changed your code to :

x <- matrix(c(strftime(as.POSIXlt(index(x)),'%m/%d/%Y,%H:%M'),
 format(x, nsmall = 5)), ncol=2)

write.csv(x, row.names=FALSE, quote=FALSE)

But I need a space between the comma and the double, like that :
The current output :
01/08/2007,00:59,1.93025
01/08/2007,01:59,1.92955
01/08/2007,02:59,1.92885

My target :
01/08/2007,00:59, 1.93025
01/08/2007,01:59, 1.92955
01/08/2007,02:59, 1.92885

Also is it possible to remove the first line ( the V1,V2 stuff ) ?

V1,V2
07/17/2008,12:18,1.960615
07/17/2008,12:18,1.940416
07/17/2008,12:18,1.931146


Thanks,

Pierre8r


      ____________________________________________________
intelligente http://mail.yahoo.fr