Skip to content

Obtaining Quick File Info for Large Data Files Stored On Disk #7169

@drag05

Description

@drag05

I wonder if it would be possible to quickly obtain some info on larger-than-memory size data stored on disk, similar to, for example:

write.table(iris, 'test.csv', sep=",",row.names=FALSE,quote=FALSE)

info = function(file) {
            tot = callr::r(
                          function(file) {
                                                  fread(file)[,.N]
                             }, package = 'data.table', args = list(file = readpath)
        )
           nmes = names(fread(file = readpath, nrows = 0L))
cat('\n found', tot, 'rows and', length(nmes), 'columns named:\n\n', sQuote(nmes), '\n')
return(invisible(list(tot, nmes)))
}

info('test.csv')

 found 150 rows and 5 columns named:

 ‘Sepal.Length’ ‘Sepal.Width’ ‘Petal.Length’ ‘Petal.Width’ ‘Species’ 

system.time(info('test.csv'))

user  system elapsed 
   0.01    0.00    0.27 

but faster than that. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions