Assessing how large a file (How much RAM it will take) will be in R before loading it

前提是你 提交于 2020-01-05 09:10:05

问题


I was wondering if there's some function that given a file name + path can asses how much RAM R will need to use it? i want to be able to know this info before I'm loading it.


回答1:


You can use 'fstat' http://linux.die.net/man/2/fstat

It will report information about your file, such as actual filesize.

struct stat {
    dev_t     st_dev;     /* ID of device containing file */
    ino_t     st_ino;     /* inode number */
    mode_t    st_mode;    /* protection */
    nlink_t   st_nlink;   /* number of hard links */
    uid_t     st_uid;     /* user ID of owner */
    gid_t     st_gid;     /* group ID of owner */
    dev_t     st_rdev;    /* device ID (if special file) */
    off_t     st_size;    /* total size, in bytes */
    blksize_t st_blksize; /* blocksize for file system I/O */
    blkcnt_t  st_blocks;  /* number of 512B blocks allocated */
    time_t    st_atime;   /* time of last access */
    time_t    st_mtime;   /* time of last modification */
    time_t    st_ctime;   /* time of last status change */
};


来源:https://stackoverflow.com/questions/24299125/assessing-how-large-a-file-how-much-ram-it-will-take-will-be-in-r-before-loadi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!