LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reading from Spreadsheet problem

Ok, I can write and read data from excel files but now when I try to delimit by use of tabs still I get breaking down of numbers. For example:

if I have 3 -7 92 10049

the first run interation of this inside the while loop is 3 which is fine, then alot of times I will get a 0 then a -7 then a 0 then a 7, 0, 92, 0, 2, 0, 10049, 49, 9, 0.

If you can see the pattern it is reading numbers and then breaking them apart space by space. So for 48897872 it would be 48897872, 4889787, 488978, 48897,4889, 488, 48, 4. If there are 0's in the number it just skips them. Also for some reason in between iterations in the while loop I have about a second, (I am using a wait time function), but I will get a 0 in bet
ween numbers.

What I would like to do is keep the numbers together so for 4908 -83 7 on the first iteration I get 4908 the second -83 and the third 7 with no zero's in between.


I am going to attach the VI that I am workign with and the file that it is reading from.

THanks,

Brian
Download All
0 Kudos
Message 1 of 7
(2,958 Views)
What you're doing doesn't make an awful lot of sense. You are repeatedly reading in the same text file and keep incrementing the character offset so you start the read at a different place each time. That's why you see spaces and zeroes. Why don't you just put the Read From Spreadsheet outside the while loop. It reads the entire contents so there's no need for it inside unless there's some strange thing that I don't understand.
0 Kudos
Message 2 of 7
(2,958 Views)
Hi Brian

I'm not certain I fully understand what your after, your file only has one row and it seems you are looking for two (Deck 1 Deck 2). When you connect the loop index to the 'Read from spreadsheet file' it indexes one character each time through the loop, not one number.

Take a look at the picture, it may be what your looking for, or give you some ideas.

Ian
Message 3 of 7
(2,958 Views)
Dennis,

What I am trying to do is to read the next number each time that a button is pressed. I know in the spreadsheet that I posted that I only had one line, I was trying to start simple and just work with the A boolean button, Everytime I press it I am trying to get the next number in the file, (which is seperated by a tab). So for example if I pressed A the first time I would get the first number, and then some time later when I pressed A again (while the VI is still running), I would then get the second number and so on. This is why I have the wile loop iteration connected to the offset read charector on the read from spreadsheet file. In this way for the 10th press of the boolean I will have the 10th iteration and get the 10th value
from the file.

I hope this make a little more sense?

Thanks,

Brian
0 Kudos
Message 4 of 7
(2,958 Views)
Ian,
Please refer to the reply that I gave to Dennis, any new ideas?


Thanks,

Brian
0 Kudos
Message 5 of 7
(2,958 Views)
Brian

Load your file outside the loop, add a shift register for each row of data and initialise to 0. Add a case structure inside the loop for each shift register and put a +1 increment inside each true state and feed the signal through unaltered in the false state. These can now be used to index the 2D array which was loaded from your file.

If you need many rows you could use an array of buttons along with an array of indexes.

Hope this helps.
0 Kudos
Message 6 of 7
(2,958 Views)
I think I understand what you're trying to do but you're going about it the wrong way. The function Read From Spreadsheet will either all rows or one row at a time - not one value at a time. You'll have to use other file read functions or read the file once and index one element at a time out of the array. That's probably the most effecient method.
0 Kudos
Message 7 of 7
(2,958 Views)