Skip to content

FR: in colClasses of fread, allow column names not present in actual table #1602

@aushev

Description

@aushev

I often need to read multiple tables that share some (but not all) columns which would be passed to colClasses. It would be then convenient to make one vector with all those column names, i.e. instead of

chrcols1 <- c('colA', 'colB')
dt1 <- fread(file1, colClasses=list(character=chrcols1))
chrcols2 <- c('colA', 'colC')
dt2 <- fread(file2, colClasses=list(character=chrcols2))
# etc

use

chrcolsAll <- c('colA', 'colB', 'colC')
dt1 <- fread(file1, colClasses=list(character=chrcolsAll))
dt2 <- fread(file2, colClasses=list(character=chrcolsAll))

Right now this is not allowed ( "Column name '%s' in colClasses[[%d]] not found" ) but instead of throwing an error we could just exclude those column names from further processing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions