05-21-2007 06:33 AM
05-21-2007 08:41 AM
05-21-2007 09:27 AM
Good information from Mike. I just wanted to add some ideas to make it more efficient so that you don't have to build an array every time you read a chunk of data.
1. You can estimate the number of lines of the file if you read the file size and one row of data. File size / length of a line ~ number of lines. You could add 100 or so to this number to make room for everything, or you could just add to it when you hit the end of the array. Use this to initialize an array of the size you need for the column and use Replace Array Subset.vi to add data to it.
2. Make sure you keep the file open and pass the refnum in a shift register in this loop that you'll use to read the file. This will be faster than using something like Read from Spreadsheet File.vi, which opens and closes the file every time it reads.
05-22-2007 02:51 AM - edited 05-22-2007 02:51 AM
Thank you for your help. Unfortunately I already failed at 1 and 2 of Mikes explanation. Perhaps you could give me a hint with a small example?
Thanks a lot in advance.
Greets
Kane
PS: Unfortunately I don't have any possibilities to change the data format. I get the data and have to eat it as they come ![]()
Message Edited by NetizenKane on 05-22-2007 02:52 AM
05-22-2007 06:45 AM
05-22-2007 08:18 AM - edited 05-22-2007 08:18 AM
No problem, here is an example in 8.2. Like I said in the comment, I haven't tested it. It should get you started though. If you have trouble getting it to run, post back and I'll take a look at it. Edit: Woohoo! I'm a veteran!

Message Edited by Marc A on 05-22-2007 09:19 AM
Message Edited by Marc A on 05-22-2007 09:20 AM
05-22-2007 09:35 AM
I was playing around with this and found a problem. You need to wire an end of line constant to the 'delimiter' input of Array to Spreadsheet String. Since you're reading a 1D array of lines from the file, this will create the spreadsheet string correctly with the end of line after each array element, which are already delimited by tabs.
I also got rid of the error cluster shift register and just wired the error to the stop terminal of the loop so that the error wouldn't propagate to the Close File node.
05-23-2007 02:54 AM
05-23-2007 08:16 AM
OK, I had to change a few things to get it to work with that data. The problem is that your data isn't consistently the same length, so the estimation of the length of the array wasn't working too well. If you format all your data to be the same width, it will work a lot better. I added 1000 instead of 50 to the estimate and it worked, but I can't say this will work for any amount of data you throw at it.
Here is the new VI, saved in 8.0.
05-23-2007 08:25 AM