Is it possible to get the number of rows in a CSV file without opening it?

前端 未结 4 1528
逝去的感伤
逝去的感伤 2020-12-03 10:13

I have a CSV file of size ~1 GB, and as my laptop is of basic configuration, I\'m not able to open the file in Excel or R. But out of curiosity, I would like to get the numb

4条回答
  •  攒了一身酷
    2020-12-03 10:27

    Here is something I used:

    testcon <- file("xyzfile.csv",open="r")
    readsizeof <- 20000
    nooflines <- 0
    ( while((linesread <- length(readLines(testcon,readsizeof))) > 0 ) 
    nooflines <- nooflines+linesread )
    close(testcon)
    nooflines
    

    Check out this post for more: https://www.r-bloggers.com/easy-way-of-determining-number-of-linesrecords-in-a-given-large-file-using-r/

提交回复
热议问题