12-19-2009 09:39 PM
Hi.
I'm new to labview and have a problem but probably quite simple to those who know. I want to read a text file for display using a timer in a for or while loop. The problem is that no matter where I put the read block and how I time it all my data comes in at once, it reads it in one iteration and stores it in my array. i want to control the iteration speed using a timer which is fairely straight forward, but I cant read the file in one element at a time.
Also is it possible to access the elements in the stored array?
All help greatly appreciated.
Thanks,
Jim
Solved! Go to Solution.
12-19-2009 10:26 PM - edited 12-19-2009 10:27 PM
You really should not read the file one line or one eleiment at a time. Read it all at once outside of any loop and if you wire the array into a for loop, it will be auto-indexed and you can display one element at a time. The code below would plot every element in the array and then stop. You would use a while loop if you wanted to continuously display the array. An Index Array function along with a Quotient & Remainder would do the trick. Experiment and post your code if you get stuck.
p.s. You posted to the digital I/O board. This question is unrelated to hardware. Post similar questions to the LabVIEW board. You should also see about the free tutorials.
12-20-2009 09:54 AM
Thanks for the reply.
The problem with this is I only seem to be reading the first element continuously. I'm sure its some simple parameter setting but not so simple when you dont know how. There are 4 columns and lots of rows in the file. Ideally I would like to plot the first and third columns over time. is there a function that can split the data? My program is attached.
Thanks again,
Jim.
12-20-2009 11:05 AM - edited 12-20-2009 11:11 AM
You seem to have posted a word file instead of the actual VI.
What is the format of the file you are trying to read? You did not mention that there were multi-columns. In this case, you should be passing in the 2D Array output. The Read From Spreadsheet File defaults to reading tab delimited files. Is that what you have? The various parameters are explained by turning on Context Help.
Attach a small example of your data file.
Yes, of course there is a function that splits the data. Index Array is one. Split Data is another.
p.s. Wiring the N terminal is not necessary and using the Build Array on the 1D output seems silly.
12-20-2009 11:28 AM
The first few lines of the file are attached.
Jim
12-20-2009 11:55 AM - edited 12-20-2009 11:55 AM
Yes, you did not specify the correct delimiter. The data in the file is separated by commas.
You said you wanted to plot column 3 but that is all zeroes. In any case, this is what you would do.
Please take the time to take those tutorials!
12-20-2009 01:47 PM
Please forgive my slowness.
As in the vi attached by using auto indexing I get errors. When I disable it it works but only records 1 element (the first ) in the array and displays only the first elements of the two columns. Do I have to convert the data somehoe to let me use auto indexing?
Thanks again.
Jim.
btw. i have gone through tutorials and help but cant seem to nail it.
12-20-2009 01:56 PM
12-20-2009 04:08 PM
Thanks Dennis.
Got that working now.
Happy xmas
Jim