<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><div><blockquote type="cite" class="clean_bq" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Can fread read from a multi-line character vector, similar to the read.table <br>text= argument?<span class="Apple-converted-space"> </span></blockquote></div><p>No.</p><div><div><blockquote type="cite" class="clean_bq" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Feature request? </blockquote></div><p>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.</p><div><br class="Apple-interchange-newline"></div></div></div> <br> <div id="bloop_sign_1446483308671941888" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Arun</div></div> <br><p class="airmail_on">On 29 October 2015 at 00:18:13, Douglas Clark (<a href="mailto:clark9876@airquality.dk">clark9876@airquality.dk</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>Can fread read from a multi-line character vector, similar to the read.table
<br>text= argument? Feature request?
<br>
<br>I am importing the output "print" file from a dispersion model (a fortran
<br>program). The output file consists of 4000+ lines of text, tables of model
<br>parameters, and tables of model results, all of varying lengths. I read the
<br>entire file into a character vector variable, such as mylines <-
<br>readLines(...), and then use regular expressions to "clean" the text and
<br>locate the starting and ending lines of the tables to be imported.
<br>
<br>I tried to use fread(mylines[start:stop]), but fread doesn't accept a vector
<br>of character strings as input -- only a length 1 character vector (ie all in
<br>one string).
<br>
<br>read.table does allow reading from a multi-line character vector variable,
<br>using the text= argument, ie read.table(text = mylines[start:stop],...).
<br>
<br>fread will also read it, if I collapse the multi-line character vector into
<br>a single string using paste0 or stri_flatten, as in
<br> fread(paste0(mylines[start:stop], collapse = "\n"))
<br>or
<br> fread(stri_flatten(mylines[start:stop], collapse = "\n"))
<br>
<br>But it would be nice if I could skip the collapse step.
<br>
<br>Does fread have a way to directly read from a multi-line character vector
<br>without flattening it -- like the text= argument in read.table ? Or is
<br>there an easier approach? If not, should this be a feature request?
<br>
<br>
<br>
<br>--
<br>View this message in context: http://r.789695.n4.nabble.com/fread-with-multi-line-character-vector-input-tp4714096.html
<br>Sent from the datatable-help mailing list archive at Nabble.com.
<br>_______________________________________________
<br>datatable-help mailing list
<br>datatable-help@lists.r-forge.r-project.org
<br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
<br></div></div></span></blockquote></body></html>