加快vbs中文本文件的循环速度
下午好,
我的代码有问题,我循环遍历文本文件。该文本文件大约有 10,000 行,因此我想出了使用 instr 搜索函数来查找行号,方法是查找出现“测试名称”的字符号,然后使用 mid 函数并向左计数来查找行号。
例如。
000004###24503###开设帐户Web ISA single###2#########请输入您的第一个姓名.###假##########先生############callie###################### #################################################### #################### #################################################### #################################################### #################################### #################################################### ################################################666 ###Imagenericpassword###Ops##### #################################################### #################################################### ##############################现金ISA 2009 / 2010################################################## #################################################### ################ #################################################### #################################################### ##################
因此,在本例中,它会找到“Open Account Web ISA single”并向左计数以找到 000004。因此,这可以节省我循环遍历 10,000 行的时间。
所以接下来我使用 ### 作为分隔符将这一行分割成一个数组,这会导致很多空的“列”,因为当我连接 Excel 中的数据时它们是空的。这使得我总共有大约 247 列。我的问题是我不想真正循环 247 列,因为其中很多包含......好吧什么也没有。有没有更快的方法让我做到这一点?
我以前用过excel,但是速度太慢了。
Good afternoon,
I have a problem with my code where im looping through a textfile. The textfile has approx 10,000 lines so I came up with using the instr search function to find the line number by finding the character number in which the "test name" appears and then using the mid function and counting left to find the line number.
eg.
000004###24503###Open Account Web ISA single###2#########Please enter your first name.###False#########Mr############callie####################################################################################################################################################################################################################################################################################################################################666###Imagenericpassword###Ops#######################################################################################################################################Cash ISA 2009 / 2010##########################################################################################################################################################################################################################################
So in this case it finds "Open Account Web ISA single" and counts left to find 000004. So this saves me looping through 10,000 lines.
So next I split this line into an array using ### as a delimeter, this results in lots of empty "columns" since they were empty when i concatinated the data from excel. This leaves me with a total of around 247 columns. My issue is I dont want to really loop through 247 columns since lots of them contain...well nothing. Is there a quicker way for me to do this?
I used to use excel but its far too slow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以删除空列:
这是您的示例的结果:
You can remove the empty columns:
This is the result for your example: