[datatable-help] fread with multi-line character vector input

Arunkumar Srinivasan aragorn168b at gmail.com
Mon Nov 2 17:56:31 CET 2015


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 (clark9876 at airquality.dk) 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  
datatable-help at lists.r-forge.r-project.org  
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20151102/a75b640e/attachment.html>


More information about the datatable-help mailing list