Paul.j
Paul.j

Reputation: 834

how to fix "Error in textConnection(text) : all connections are in use" in R?

In R I tried to read a fairly large csv file (4200KB) but encountered the following error. It is strange that I ran the same command before without any problem. The only thing changed was I recently updated my R from 3.01 to 3.03. Not sure this would affect anything.

If anyone has a thought/experience on how to fix it, it would be much appreciated!

> xml2csv(xmlFile,csvFile)

 Error in textConnection(text) : all connections are in use 

>traceback()

9 textConnection(text) 

8 read.table(text = data, sep = sep, fill = TRUE, row.names = NULL, 
    header = FALSE, blank.lines.skip = FALSE, strip.white = TRUE, 
    col.names = paste("v", sequence(max(x)))) 

7 read.concat(a, names(data[split.col]), sep) 

6 concat.split.compact(data = data, split.col = split.col, sep = sep, 
    drop = drop, fixed = fixed) 

5 concat.split(data[split.cols[x]], split.cols[x], seps[x], drop = TRUE) 

4 FUN(1:686[[125L]], ...) 

3 lapply(seq_along(split.cols), function(x) {
    concat.split(data[split.cols[x]], split.cols[x], seps[x], 
        drop = TRUE)
}) 

2 concat.split.multiple(Y, as.vector(colnames(Y))[-c(1:2)], ":") at IFN_functions.r#115

1 xml2csv(xmlFile, csvFile)

Upvotes: 2

Views: 3642

Answers (2)

speleo
speleo

Reputation: 123

The limit of maximum number of open connections is currently set to be 128. It is hardcoded into the R source code as constant / macro NCONNECTIONS in src/main/connections.c

You may look at the workaround posted on Wishlist for R: https://github.com/HenrikBengtsson/Wishlist-for-R/issues/28

Upvotes: 0

user3471268
user3471268

Reputation:

The error message is fairly self-explanatory; all text connections are in use :). Are you using other connections in the code? And if so, are you closing them after you're done with them with close(con)?

Upvotes: 1

Related Questions