Hi, I am making multiple calls to gzfile() via read.table(), e.g.> x <- read.table( gzfile( "xxx.gz" ) )After i do this many times (I haven't counted, but probably between 50 and 100 times) I get the error message: Error in open.connection(file, "r") : unable to open connection In addition: Warning message: cannot open compressed file 'xxx.gz' however, I also find that:> showConnections()description class mode text isopen can read can write so there are no (apparently) open connections. Calling closeAllConnections() does not fix the problem. I have to quit and re-start R. I am using R 2.5.0 on a Mac (OSX 10.4.9). Anyone know if this is a bug or a 'feature'? I see from the gzfile help that: In general functions using connections will open them if they are not open, but then close them again, so to leave a connection open call 'open' explicitly. Thanks. -David [[alternative HTML version deleted]]
On 03/07/2007 1:37 PM, David Reiss wrote:> Hi, > I am making multiple calls to gzfile() via read.table(), e.g. > >> x <- read.table( gzfile( "xxx.gz" ) ) > > After i do this many times (I haven't counted, but probably between 50 and > 100 times) I get the error message: > > Error in open.connection(file, "r") : unable to open connection > In addition: Warning message: > cannot open compressed file 'xxx.gz' > > however, I also find that: > >> showConnections() > description class mode text isopen can read can write > > so there are no (apparently) open connections. Calling closeAllConnections() > does not fix the problem. I have to quit and re-start R. > I am using R 2.5.0 on a Mac (OSX 10.4.9). > > Anyone know if this is a bug or a 'feature'? I see from the gzfile help > that: > > In general functions using connections > will open them if they are not open, but then close them again, so > to leave a connection open call 'open' explicitly.You didn't give a reproducible example, so I couldn't say. When I create a gzipped version of a write.table output and run for(i in 1:1000) read.table(gzfile(f)) in R 2.5.0 I don't see a problem. This is on Windows, but I doubt that makes a difference. Duncan Murdoch
Maybe Matching Threads
- file descriptor leak in getSrcLines in R 2.10.0 svn 48590
- cannot destroy connection (?) created by readLines in a tryCatch
- unlink() is not synchronized with existing connections (PR#783)
- cannot destroy connection (?) created by readLines in a tryCatch
- cannot destroy connection (?) created by readLines in a tryCatch