01-03-2011 02:11 AM
let me come back to my original question, I probably need to clarify it
I have a 80MB text file and need to read into a 2D array.
but read spread sheet.vi doesn't work, as it is out of memory.
I tried low-level vis, but seems very complicated. do you know any good way to read it?
thanks
jack
01-03-2011 02:18 AM
01-03-2011 07:41 AM
Hi, altenbach,
Thank you very much. I tried that. It's very good. But right now I have another problem,how can I read chunk of files or part of lines sequencely?
for example, my text file have unknown number of lines, do u know how to read them in a fixed number of times? how can we get this fixed number?
thanks
jack
01-04-2011 11:20 AM
Hi lgG_Kylin,
Try taking a look at the Advanced File Functions palette. The Get File Size VI and Get File Position VI should help you.
Regards,
Starla T.
01-04-2011 11:43 AM
01-04-2011 12:06 PM
When trying to read in sections the read text file will let you specify how many rows you want to read (right click on the VI and hit read rows). You use the read text file in a for loop, you wire the file reference wire to a shift register so the file position is fed to the next iteration of the loop. You are now reading in chunks. Now do everything else Altenbach has said with the get file size vi (to figure out how many iterations of for loop operation you need). You should be able to handle your data processing in the for loop. You haven't told us what you are doing with the data so any number of things could be what you are looking for.
Once again, its much easier to get help if you give people a lot of information about your problem.
01-04-2011 12:48 PM
great, this is useful.
thank you very much 🙂
01-04-2011 12:54 PM - edited 01-04-2011 12:55 PM
Reading in sections only makes sense if you also process in sections and never have the entire file in memory. Just reading in sections and then assemble the whole in memory would again be inefficient.
As I explained, unless you use binary files or text files with a fixed number of characters/line a lot of work needs to be done to find where each line ends. (even if you use the built-in tools!)
Reading an 80MB string is not that hard, and the resulting DBL array is only a small fraction of that size in memory.