Skip to content

nrows=0 interferes with proper sep detection #2747

Description

@st-pasha

(even if sep is given explicitly):

> fread("A,B,C\n1,2,3\n3,4,5\n0,0,0\n", nrows=0)
Empty data.table (0 rows) of 1 col: A,B,C
> fread("A,B,C\n1,2,3\n3,4,5\n0,0,100\n", nrows=0, sep=',')
Empty data.table (0 rows) of 1 col: A,B,C

Expected result: a 0 rows x 3 columns data.table with columns "A", "B", and "C"

Also, documentation says

nrows=0 returns the column names
and typed empty columns determined by the large sample;
useful for a dry run of a large file or to quickly check
format consistency of a set of files before starting to read
any of them.

As far as I understand, this is no longer accurate.

Activity

  1. added this to the milestone on Apr 13, 2018
  2. modified the milestones: v1.11.0, on Apr 29, 2018
  3. mattdowle commented on Jan 11, 2019

    @mattdowle
    Member

    Not sure when this was fixed, but it looks fixed now. Will add tests.

    > fread("A,B,C\n1,2,3\n3,4,5\n0,0,0\n", nrows=0)
    Empty data.table (0 rows) of 3 cols: A,B,C
    > fread("A,B,C\n1,2,3\n3,4,5\n0,0,100\n", nrows=0, sep=',')
    Empty data.table (0 rows) of 3 cols: A,B,C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions