Skip to content
Back to formatted view

Raw Message

Message-ID: <BANLkTinuqmZtLtPiugmJs3CLOMaShbDxPA@mail.gmail.com>
Date: 2011-04-04T21:30:36Z
From: Andrew Yee
Subject: how to handle no lines in input with pipe()

This has to do with using pipe() and grep and read.csv()

I have a .csv file that I grep using pipe() and read.csv() as follows:

read.csv(pipe('grep foo bar.csv'))

However, is there a way to have this command run when for example,
there is no "foo" text in the bar.csv file?  I get an error message
(appropriately):

Error in read.table(file = file, header = header, sep = sep, quote = quote,  :
  no lines available in input

Is there a way to "inspect" the output of pipe before passing it on to
read.csv()?

Thanks,
Andrew