-
Notifications
You must be signed in to change notification settings - Fork 289
Closed
Description
- When
col_typesis specified andskipis equal to or greater than the number of actual rows,read_csv()returns a data.frame with 1 row. - When
col_typesis not specified andskipis equal to or greater than the number of actual rows,read_csv()throws an error.
I think Case1 is wrong to return a row of results when there aren't any, and should probably return a zero-row data.frame.
EDIT: Case 2 is handled OK i.e. If column types aren't specified, and there are no rows from which to infer type, you can't really return anything sensible.
I found this inconsistency when doing chunked reads from a large CSV file, and a zero-row data.frame was going to be an indicator that I'd run out of data.
> read_csv("1,2\n3,4", col_names=c('a', 'b'), col_types='ii')
Source: local data frame [2 x 2]
a b
1 1 2
2 3 4
>
> read_csv("1,2\n3,4", col_names=c('a', 'b'), col_types='ii', skip=2)
Source: local data frame [1 x 2]
a b
1 NA NA
>
> read_csv("1,2\n3,4", col_names=c('a', 'b'), skip=2)
Error: You have 2 column names, but 0 columnsMetadata
Metadata
Assignees
Labels
No labels