I'm trying to split a csv file by column Customer.Code and write the resulting Dataframes to seperate csv files.
splittit<- function(file){
data<-read.csv(file)
data<-split(data,data$Client.Code)
x<- length(data)
for(i in x){
custdata<- data[i]
custdata<- as.data.frame(custdata)
customer<- custdata[1,18]
customer<- as.vector(customer)
filename<- paste(as.character(customer),".csv")
write.csv(custdata, file= filename)
}
}
If anyone can help me as to why only the first csv file is being written i would be very grateful.
Thanks in advance