Can fread read from a multi-line character vector, similar to the read.table 
text= argument? 
No.

Feature request? 
Please do, but check the existing issues using ‘label:fread’ before filing 
please. Even if it couldn’t be done any efficiently, it might be convenient.



-- 
Arun

On 29 October 2015 at 00:18:13, Douglas Clark ([email protected]) wrote:

Can fread read from a multi-line character vector, similar to the read.table  
text= argument? Feature request?  

I am importing the output "print" file from a dispersion model (a fortran  
program). The output file consists of 4000+ lines of text, tables of model  
parameters, and tables of model results, all of varying lengths. I read the  
entire file into a character vector variable, such as mylines <-  
readLines(...), and then use regular expressions to "clean" the text and  
locate the starting and ending lines of the tables to be imported.  

I tried to use fread(mylines[start:stop]), but fread doesn't accept a vector  
of character strings as input -- only a length 1 character vector (ie all in  
one string).  

read.table does allow reading from a multi-line character vector variable,  
using the text= argument, ie read.table(text = mylines[start:stop],...).  

fread will also read it, if I collapse the multi-line character vector into  
a single string using paste0 or stri_flatten, as in  
fread(paste0(mylines[start:stop], collapse = "\n"))  
or  
fread(stri_flatten(mylines[start:stop], collapse = "\n"))  

But it would be nice if I could skip the collapse step.  

Does fread have a way to directly read from a multi-line character vector  
without flattening it -- like the text= argument in read.table ? Or is  
there an easier approach? If not, should this be a feature request?  



--  
View this message in context: 
http://r.789695.n4.nabble.com/fread-with-multi-line-character-vector-input-tp4714096.html
  
Sent from the datatable-help mailing list archive at Nabble.com.  
_______________________________________________  
datatable-help mailing list  
[email protected]  
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help  
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to