我有一个巨大的(4GB)
XML文件,我目前正在使用linux“split”函数(每25,000行 – 不是字节)分成块.这通常很有效(我最终得到了大约50个文件),除了一些数据描述有换行符,因此块文件经常没有正确的结束标记 – 而且我的解析器在处理过程中中途窒息.
示例文件:(注意:通常每个“列表”xml节点应该在它自己的行上)
<?xml version="1.0" encoding="UTF-8"?> <listings> <listing><date>2009-09-22</date><desc>This is a description WITHOUT line breaks and works fine with split</desc><more_tags>stuff</more_tags></listing> <listing><date>2009-09-22</date><desc>This is a really annoying description field WITH line breaks that screw the split function</desc><more_tags>stuff</more_tags></listing> </listings>
然后有时我的分裂最终会像
<?xml version="1.0" encoding="UTF-8"?> <listings> <listing><date>2009-09-22</date><desc>This is a description WITHOUT line breaks and works fine with split</desc><more_tags>stuff</more_tags></listing> <listing><date>2009-09-22</date><desc>This is a really annoying description field WITH line breaks ... EOF
所以 – 我一直在阅读“csplit”,听起来它可能有助于解决这个问题.我似乎无法正确表达正确的表达……
就像是:
*csplit -k myfile.xml '/</listing>/' 25000 {50}
任何帮助都会很棒
谢谢!