计算文件中行数的最快方法 [英] Fastest way to count lines in a file

查看:146
本文介绍了计算文件中行数的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个庞大的CSV文件,我想知道其中的总行数.目前,我正在使用类似的方法,虽然效果很好,但是速度很慢:

I have huge CSV file, which I want to know the total number of rows in which. Currently I am using something like this, which works perfectly, but it's slow:

FIND /c ";" FILENAME.csv

但是我不知道这是在CSV中遍历所有行的最快方法.您可以教我什么建议或方法吗?我的CSV文件有10万多行.

But I dunno if that's the fastest way to iterate through all lines in a CSV. Any suggestions or method you can teach me? My CSV files have over 100 000 lines.

PS:请问您还可以包括执行时间吗?

PS: Please can you include the execute time aswell?

谢谢.

推荐答案

for /f "tokens=1 delims=:" %%# in ('find /c /v "" ^< FILENAME') do set "linescount=%%#"
echo %linescount%

这篇关于计算文件中行数的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆