0
votes

I have several chunks of data in csv format and I want to import them and merge them together to create a whole new csv file. however, when I try to do so, I get the following error:

Error in read.table(file = file, header = header, sep = sep, quote = quote, : no lines available in input

Below is the code that I use:

for (x in 1:50){
     print(x)
     chunks[[x]]<-mutate_geocode(chunks[[x]], location = full_address, output = "latlona")
write.csv(chunks[[x]],paste0("~/120Water Dropbox/LSLI Clients/IN/Anderson/02 - R/Data/billing_chunks_KE",x,".csv"), row.names = FALSE)
    }
    
files<-list.files(path = "~/120Water Dropbox/LSLI Clients/IN/Anderson/02 - R/Data", pattern = "billing_chunks_KE", full.names = T)
customer_billing_full<-do.call(rbind,lapply(files,read.csv))
write.csv(customer_billing_full,"~/120Water Dropbox/LSLI Clients/IN/Anderson/02 - R/Data/Customer Billing_full.csv", row.names = FALSE)

I appreciate any help.

Hi Kaveh, Can you please check if there is any format file with the given pattern in the path mentioned by you?Isa
Hi Isa, I have 50 csv files, with their names all start with "billing_chunks_KE" (billing_chunks_KE1, billing_chunks_KE2,...,billing_chunks_KE50). There is another filed named "Customer Billing_full". These files are all in cvs format. Lastly, there is a subfolder named "billing_chunks_KE" which is empty. I appreciate any help.Kaveh Ekbia
Please delete that subfolder and try your code it should work properlyIsa
Fantastic! It worked. Thank you so much, Isa. Only one thing: It gives a warning, but I don't think I should worry about it. The warning message is:Kaveh Ekbia
1: In [<-.factor(*tmp*, ri, value = c(NA, NA, NA, NA, NA, NA, NA, : invalid factor level, NA generatedKaveh Ekbia