Skip to content

read_table can't read from pipes #552

@kenahoo

Description

@kenahoo

The following does not work:

con <- pipe("perl -le 'print qq{x $_} for 1..5'")
read_table(con)
## 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementread 📖

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions