Trying to concatenate files into one Data Frame

Hey, I am trying to concatenate different CSV files into one data frame. However, seem to find this error below when I try to run the run code.

Error: Files must have consistent column names:

  • File 1 column 1 is:

Please find the code below:

files <- list.files(pattern =".csv")
act_weather_data <- data

for(i in 1:length(files)){
data <- read_csv(files, show_col_types = FALSE)
assertthat::assert_that(nrow(problems(data)) == 0,
msg="There is still problem/s, which you need to fix first")

temp <- tryCatch(
expr = { parse_date(data$Date, AU_Date_Format)},
warning = function(x) { parse_date(data$Date, AU_Date_Format)})

Date <- format(temp, AU_Date_Format)

act_weather_data <- cbind(act_weather_data, data)
}

It's hard to know unless we could see the first few lines of the CSV file. If the files were all the same layout (i.e., columns) why not read them one by one and concatenate by rows using bind_rows()? Or does the data layout prevent that?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.