I am merging all my CSV files to a single file using the below.
path = "C:\\Users\\User\\Documents\\data\\Reports\\2013"
combined2013 <- list.files(path=path,
pattern="*.csv",
full.names = TRUE) %>%
lapply(read_csv) %>%
bind_rows
combined2013["Year"] <- 2013
write.csv(combined2013,"C:\\Users\\User\\Documents\\data\\Reports\\2013\\Reports_2013.csv",
row.names = FALSE,
encoding = "utf-8")
However, this code worked earlier but now it is giving me an error as:
Error in `bind_rows()`:
! Can't combine `updated_at` <character> and `updated_at` <datetime<UTC>>.
Backtrace:
1. ... %>% bind_rows
2. dplyr::bind_rows(.)
5. vctrs::vec_rbind(!!!dots, .names_to = .id)
I have tried:
combined2013 %>% mutate(across(where(is.character), as.datetime))
But still doesn't work. Also, it adds some REDUNDANT columns during the merge:
Warning: One or more parsing issues, see `problems()` for details
Rows: 2222 Columns: 30
-- Column specification -----------------------------------------------------
Delimiter: ","
chr (21): id, title, text, video_timestamp, user_pseudo_id, created_at, ...
dbl (1): sentiment
lgl (7): video_id, collab_space_id, collab_space_title, deleted, closed...
dttm (1): updated_at
i Use `spec()` to retrieve the full column specification for this data.
i Specify the column types or set `show_col_types = FALSE` to quiet this message.
New names:
* `` -> `...29`
* `` -> `...30`
I am using LibreOffice to preserve some UTF-8 encoding as I have some German text which was not handled before during merge.