【发布时间】:2012-02-12 14:18:35
【问题描述】:
我需要能够从现有文本文件中提取数据。文本文件的结构看起来像这样......
this line contains a type of header and always starts at column 1
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains a type of header and always starts at column 1
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains a type of header and always starts at column 1
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
this line contains a type of header and always starts at column 1
this line contains other data and is always tabbed in
this line contains other data and is always tabbed in
如您所见,文本文件按部分排列。总是有一个标题行,后面跟着随机数量的其他数据行,节之间总是有一个空行。不幸的是,标题部分的命名方案或其他数据行中包含的数据没有押韵或理由......只有上述结构有点一致。我需要搜索的数据位于其他数据行之一中,仅位于其中一个部分中,该部分可能位于文本文件中的任何位置。我可以使用 FIND 命令来定位我需要查找的文本,但是一旦我这样做了,我需要能够将整个部分提取到一个新的文本文件中。我不知道如何在前面的第一个空白行上增加多少行,然后向下到下一个空白行,并提取其间的所有内容。那有意义吗?不幸的是,VBScript 根本不是这个应用程序的一个选项,否则它早就结束了。有任何想法吗?谢谢。
【问题讨论】:
标签: batch-file extract text-files