一次读取多维数组的完整Colum [英] Reading a complete Colum of a multidimensional array at once

查看:76
本文介绍了一次读取多维数组的完整Colum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,如果有人可以帮助我,我很伤心,我将非常感激
我正在使用一款软件来读取逗号分隔的文本文件,该文件有数千行,每行约有32个单词,中间用逗号分隔.
我的代码在逐行读取文件时所执行的操作从32个单词中选择11个单词并将它们输出到一个新文件中.尽管我使用了线程和进度条,但我的经理仍然不满意,但这实际上是耗时的.
因此,我在考虑是否可以将整个文本文件读取为二维数组,然后选择某些Colums在新文件上输出,这将使其工作得更快.但是我不知道如何从二维数组中读取整个列.让我们说,例如,数组将类似于array(9500)(32),其中第一个参数代表行数,第二个参数代表每行中的字段数.
有没有办法像这样的数组访问它(所有行)(15)
我正在使用vb.net 2008

非常感谢

Hi all, i was wounding if anybody can help with this I will be really grateful
I am working on a piece of software to read a comma separated text files with thousands of lines each line has around 32 word separated with a comma
What my code does at the moment it reads the file line by line choose 11 words out of the 32 and outputs them into a new file. This is actually time consuming although i used threads and a progress bar my manager still not happy.
So i was thinking if i can read the whole text file into a 2 dimensional array and then choose certain Colums to output on the new file that will make it work much faster. But i dont know how to read a whole colum from a 2 dimensional array. And let us say for example the array is gonna be like array(9500)(32) where the first argument representing the number of lines and the second represents the number of fields in each line.
Is there any way to access it like this array(all lines)(15)
I am using vb.net 2008

Many thanks

推荐答案

不,这不可能,因为同一列中每个项目的值彼此相距31个.这些值在内存中对于每一行是连续的,但是对于每一列而言却是连续的.您必须对其进行转置(列到行,行到列),但这会产生相同的开销.

祝你好运!
No this isn''t possible because the value of each item in the same column is 31 items apart from each other. The values are sequential in memory for each row, but not for each column. You would have to transpose (columns to rows and rows to columns) it but that would give the same overhead.

Good luck!


这是不可能的.您仍然必须阅读每一行,将其解析为单独的单词,然后将它们添加到您的数组中.您没有在这里节省任何时间.

尽管可以使用RegEx进行解析,但性能可能会有所提高,但没有自动"的方法.
It''s not possible. You''d still have to read each line, parse it into individual words, adding them to your array. You''re not saving anyn time here.

There''s no "automatic" way of doing it, though you might get a bit of a performance improvement using a RegEx to do the parsing.


这篇关于一次读取多维数组的完整Colum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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