Import CSVs and create a table from these files in R -
this question has answer here:
i have quick question again. me in case? didn't find solution google/ stackoverflow..
1) have lot of csv files
example:
csv 1
x date var1 var2 var3 ... 1 1/5/06 1 2 3 2 1/6/06 1 2 3 3 1/7/06 3 4 5 4 1/8/06 4 5 6 ...
csv2
x date var1 var2 var3 ... 1 1/8/06 1 2 3 2 1/5/06 1 2 3 3 1/9/06 3 4 5 4 1/3/06 4 5 6 ...
and have around 200 csv files. in csv files, lot of duplications , more (i don't want delete duplications etc, can't do..)
i single data.frame or data.table. if imported csv files, got data tables csv files. have bad solution works rows (that means, split data frames rows , create new "allcsv" data table). no nice solution (i 1:n).
maybe have experience, , can single line:
i it:
allcsv (collect csv file in 1 file)
x date var1 var2 var3 ... 1 1/5/06 1 2 3 2 1/6/06 1 2 3 3 1/7/06 3 4 5 4 1/8/06 4 5 6 1 1/8/06 1 2 3 #<–––– new csv 2 1/5/06 1 2 3 3 1/9/06 3 4 5 4 1/3/06 4 5 6 ... #<----- csv(..x)
i got answer roman lustrik (thanks link!). code coming here:
load_data <- function(path) { files <- dir(path, pattern = '\\.csv', full.names = true) tables <- lapply(files, read.csv) do.call(rbind, tables) } pollutantmean <- load_data("specdata")
Comments
Post a Comment