Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_table can't read from pipes #552

kenahoo opened this issue Nov 14, 2016 · 1 comment

read_table can't read from pipes #552

kenahoo opened this issue Nov 14, 2016 · 1 comment


Copy link

@kenahoo kenahoo commented Nov 14, 2016

The following does not work:

con <- pipe("perl -le 'print qq{x $_} for 1..5'")
## Error in isOpen(con) : invalid connection

The reason seems to be that read_table first calls fwf_empty, which opens the connection and reads from it; then it calls col_spec_standardise, which also tries to open the same connection & read from it. The latter fails because it's already been read from and can't be re-opened.

There's also another subsequent call to datasource (on line 47 in the current Git master of read_table.R) that would fail after this one.

In general, to support connections & pipes, each reading function should ensure that its file/connection is opened exactly once. Avoiding these re-opens should give better performance too.

Copy link

@hadley hadley commented Dec 22, 2016

We'll take a look at this in the context of improving connection support generally.

jimhester added a commit that referenced this issue Feb 6, 2017
jimhester added a commit that referenced this issue Feb 9, 2017
* Use a datasource for all file arguments in read_table

Fixes #552

* Explain reason behind using missing in constructor
@lock lock bot locked and limited conversation to collaborators Sep 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants