[R] Split CSV as per file size
Rantony
antony.akkara at ge.com
Fri Aug 10 11:34:27 CEST 2012
Hi here i have a code to split a csv file as per group of line.
The code given below,
------------------------------------
SplitCSVByLine <- function(DataMatrix,Destination,NoOfLineToGroup)
{
input <- file(DataMatrix, "r")
fileNo <- 1
repeat
{
myLines <- readLines(input, n=NoOfLineToGroup)
if (length(myLines) == 0) break
writeLines(myLines, sprintf(paste(Destination,"Split_File_%05d.csv"),
fileNo))
fileNo <- fileNo + 1
}
close(input)
}
---------------------------------------
But how can we split a csv file into number of other csv files as per
size(in kilo byte) ?
I tried for it manytimes .
Can any one help me ?
- Thanks in advance
Antony.
--
View this message in context: http://r.789695.n4.nabble.com/Split-CSV-as-per-file-size-tp4639880.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list