0

I have .csv data with large number of row. is there any function to split that in to multiple .csv based on same row (example based on same "location" column)? thank you

enter image description here

I tried to split my one .csv data in to several .csv data

jpsmith
  • 11,023
  • 5
  • 15
  • 36

1 Answers1

0

You can use split to split the data into a list of data frame, then lapply to write them to new csvs, e.g.

data<-read.csv("filename.csv")
datalist<-split(data,data$location)
lapply(datalist, function(dat){
write.csv(dat,paste0("data",dat$location[1],".csv"))
})
andyyy
  • 986
  • 8
  • 8