I am very new in R programming. I would be highly obliged if anyone help me to solve this problem. In a folder more than 10000 CSV files are there. Every file column names can be different. I want to create a single Data frame/ master Data which will be helpful for my further analysis.
Asked
Active
Viewed 106 times
-1
-
So you want to read in every .csv file in a given folder and then bind them together into a single data.frame? – divibisan Apr 04 '18 at 18:04
-
1Take a look at my answer at [How to make a list of data frames](https://stackoverflow.com/questions/17499013/how-do-i-make-a-list-of-data-frames/24376207#24376207). It covers reading in all files from a directory and optionally combining them. (I suggest it as a dupe.) – Gregor Thomas Apr 04 '18 at 18:05
1 Answers
0
Suppose 3 data frames with different name. #Create a vector with the csv names.
names_csv=c("a", "b", "c")
#with lapply make the same instruction for the input range
# (1:length(names_csv)) and save the result in a list.
list_dataframes= lapply(1:length(names_csv), function(i){
csv=read.csv(file=paste0(names_csv[i],".csv"))
})
#then with setNames rename each element of a list with name of csv
setNames(list_dataframes, names_csv)
I hope that this would hepl you.

nriquec
- 11
- 2