Search code examples
rreadr

Problem with importing a CSV file with extremely long column names


library(readr)

surveyData_twoConditions <- read_csv("Raw Data/Survey Data/fileName_extremelyLongColumnNames.csv", 
                           col_types = cols(`Start Date` = col_character()))

I suspect that the column which is giving me problem is the following:

What should be the output of the following code below?

 
public class Test {
    public static void main(String args[]) {   
             System.out.println("Hello World")
    } 
}

Error while importing:

ansi_strwrap(text, exdent = exdent, width = app$get_width(extra = padding)):
! Internal error in cli::ansi_strwrap() Type .Last.error to see the more details.

Backtrace:
 1. readr::read_csv("Raw Data/Survey Data/fileName_extremelyLongColumnNames.csv", …
 2. vroom::vroom(file, delim = ",", col_names = col_names, col_types = col_types, …
 3. vroom:::vroom_(file, delim = delim %||% col_types$delim, col_names = col_names, …
 4. (function (spec, num_cols, col_names, col_select, name_repair) …
 5. vctrs::vec_as_names(col_names, repair = name_repair)
 6. vctrs:::describe_repair(c("Start Date", "End Date", "Response Type", …
 7. rlang::names_inform_repair(orig_names, names)
 8. rlang::inform(message = message, class = "rlib_message_name_repair")
 9. base::withRestarts(muffleMessage = function() NULL, { …
10. base::withOneRestart(expr, restarts[[1L]])
11. base::doWithOneRestart(return(expr), restart)
12. base::signalCondition(cnd)
13. base::conditionMessage(cond)
14. rlang:::conditionMessage.rlang_message(cond)
15. rlang::cnd_message(c)
16. rlang:::cnd_message_format(cnd, ...)
17. local cli_format(glue_escape(lines))
18. rlang:::.rlang_cli_format(x, cli::format_message)
19. cli::cli_format(x, .envir = emptyenv())
20. cli::cli_fmt((function() { …
21. cli:::cli__fmt(rec, collapse, strip_newline)
22. base::do.call(app[[msg$type]], msg$args)
23. (function (text, id = NULL, class = NULL) …
24. cli:::clii_bullets(app, text, id, class)
25. base::lapply(seq_along(text), function(i) { …
26. local FUN(X[[i]], ...)
27. app$text(text[[i]])
28. cli:::clii_text(app, text)
29. app$xtext(text)
30. cli:::clii__xtext(app, text, .list = .list, indent = indent, padding = padding)
31. cli::ansi_strwrap(text, exdent = exdent, width = app$get_width(extra = padding))
32. cli:::throw(cli_error("Internal error in {.fun cli::ansi_strwrap}"))

Now, I can shorten the column name (which is a solution) however, this error only happens in one of the PCs and not others. I don't get this error when working on my office PC. I have designed an entire workflow using the extended column names and I don't want to tweak the column names to address this issue. I'm looking for a way to add some code (and not change the column names present in the data file).

I have taken the following steps but the issue remains:

  1. Reinstall readr and tidyverse

Here's the info of my PC (is causing the problem):

> packageVersion("readr")
[1] ‘2.1.4’

> R.version
               _                                
platform       x86_64-w64-mingw32               
arch           x86_64                           
os             mingw32                          
crt            ucrt                             
system         x86_64, mingw32                  
status                                          
major          4                                
minor          2.1                              
year           2022                             
month          06                               
day            23                               
svn rev        82513                            
language       R                                
version.string R version 4.2.1 (2022-06-23 ucrt)
nickname       Funny-Looking Kid  



Solution

  • Copying the answer from this post: https://github.com/tidyverse/readr/issues/1475

    Using read_csv(..., name_repair = "unique_quiet") fixed the issue.