XML文件的长度 [英] Length of an XML file

查看:86
本文介绍了XML文件的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大小为31 GB的XML文件.我需要找到该文件中的总行数.我知道命令wc -l会给我同样的效果.但是,执行此操作花费的时间太长.有没有更快的机制来查找大文件中的行数?

I have an XML file of size 31 GB. I need to find the total number of lines in that file. I know the command wc -l will give me the same. However it's taking too long to perform this operation. Is there any faster mechanism to find the number of lines in a large file?

推荐答案

31个演出是一个非常大的文本文件.我敢打赌它会压缩到约1.5个演出.我将以压缩格式开始创建这些文件,然后可以通过wc流式传输该文件的解压缩版本.这将大大减少用于处理此文件的I/O和内存量. gzip可以读写压缩流.

31 gigs is a really big text file. I bet it would compress down to about 1.5 gigs. I would create these files in a compressed format to begin with then you can stream a decompressed version of the file through wc. This will greatly reduce the amount of i/o and memory used to process this file. gzip can read and write compressed streams.

但我还要发表以下评论:

But I would also make the following comments:

  • 行号并不是真正有用的XML,因为忽略了元素之间的空格(混合内容除外).您真正想了解什么数据集?我敢打赌,元素计数会更有用.
  • 确保您的xml文件没有不必要的冗余,例如,您是否在整个文档中重复相同的名称空间声明?
  • 如果尝试查找快速信息集

这篇关于XML文件的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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