hannes / MonetDBLite

MonetDB reconfigured as a library
108 stars 11 forks source link

monetdb.read.csv should accept file connections #162

Closed ajdamico closed 6 years ago

ajdamico commented 7 years ago
library(DBI)
library(MonetDBLite)

tf <- tempfile()
write.csv( mtcars , tf , row.names = FALSE )
this_conn <- file( tf , 'r' )

monetdb.read.csv( db , this_conn , 'tablename' )

need to write testthats once this is implemented

ajdamico commented 7 years ago

lapply doesn't work nicely with file connections

tf1 <- tempfile()
tf2 <- tempfile()
write.csv( mtcars , tf1 , row.names = FALSE )
write.csv( mtcars , tf2 , row.names = FALSE )

con1 <- file( tf1 , 'r' )
con2 <- file( tf2 , 'r' )

# fails because of this line..
c( con1 , con2 )

# works
lapply( c( tf1 , tf2 ) , read.csv )

# works
lapply( list( con1 , con2 ) , read.csv )

con1 <- file( tf1 , 'r' )

# fails
lapply( con1 , read.csv )

# works
lapply( list( con1 ) , read.csv )
hannes commented 7 years ago

should be simple to add, if it is possible to get a file name from the connection. Seems possible summary(file("/tmp/mtcars"))$description