[R] Reading several tables from stdin

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Thu Jun 14 04:16:00 CEST 2012


Your expectations of response time are out of line for a mailing list.  The subject of your question might or might not be appropriate here depending on  how portable you want the solution to be.

Your dependence on operating-system-specific features (ctrl-d as eof) and expectation that such features will allow you to squeeze multiple files into a single file (they usually don't) are also problems. You also didn't supply the output of sessionInfo so we don't even know your environment. Perhaps a (re)read of the posting guide is in order?

One simple approach would be to write the tables to temporary files that your R script would delete after reading. You could then simply pass the names of the files in your stdin.

If you are bound and determined to put the data in one stream, you will probably need to wrap it in some higher-level format and split the tables out of it. One option there would be XML. Alternatively, you could define your own protocol, read all the data in with readLines, and parse it out yourself.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Julio Sergio <juliosergio at gmail.com> wrote:

>Julio Sergio <juliosergio <at> gmail.com> writes:
>
>> 
>> I'm trying to write a Rscript program capable of reading several
>tables from 
>the 
>> standard input. The problem is that the tables aren't in files
>because they 
>> ...
>> Do you have any comments on this?
>> 
>> Thanks,
>
>
>Well, maybe I'm not posting this message in the right forum ...
>Uhmm, could anyone tell me where to post this?
>
>Thanks,
>
>--Sergio
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list