LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

spreadsheet to array

Solved!
Go to solution

Hi,

I am trying to read from a spreadsheet.

PressDir=-1,1,-1,1

 

how would I make this work?

I think my conversion code is wrong. 

But I have tried everything.

 

untitled.PNG

Message Edited by krispiekream on 04-06-2010 11:13 AM
Best regards,
Krispiekream
0 Kudos
Message 1 of 11
(3,300 Views)

Try wiring an empty array of the correct dimensionality (1D?) and datatype (U8?) to the "array type" input in the lower left.

 

(You can also hover over the broken wire to get more information on the problem. Most likely, you get a 2D array by default. You are also not telling us what the datatype of the cluster component PressDir is. Is it a 1D array? This is impossible to solve from the current picture, but the above is probably a good guess at a possible solution. Next time, attach the actual VI to make things clearer).

Message Edited by altenbach on 04-06-2010 09:21 AM
Message 2 of 11
(3,295 Views)

the "PressDir: does looks like a 1D array from the attached picture to me...

 

Guru

Regards
Guru (CLA)
Message 3 of 11
(3,285 Views)

Guruthilak wrote:

the "PressDir: does looks like a 1D array from the attached picture to me...


 

How can you possibly tell from the looks??? Looks cannot help here, only logic deduction. 😄
Message 4 of 11
(3,281 Views)

Judging from your screencapture, it looks like you want your variable "PressDir" to be represented as an iteger. Therefore, I assume you want to be able to read in a spreadsheet string as a boolean array, and then format the boolean array into an integer. (i.e. the array [1,0,0,1] would translate to the number 1001 in binary, or 9 decimal).

 

Here is one way of acheiving that result:

spreadsheet_string.png

 

Hopefully that helps. Good luck.

Message 5 of 11
(3,255 Views)
You can remove the For Loop from around your step 3 and the code will still work.
Message 6 of 11
(3,249 Views)

TurboPhil wrote:

Judging from your screencapture, it looks like you want your variable "PressDir" to be represented as an iteger. Therefore, I assume you want to be able to read in a spreadsheet string as a boolean array, and then format the boolean array into an integer. (i.e. the array [1,0,0,1] would translate to the number 1001 in binary, or 9 decimal).


 

Many things don't make a lot of sense here. Why would you scan it as a DBL array since there are only integers? The original problem has 1 and -1, not 1,0, and we don't know what other possible value there are, maybe -1, 0, 1? I also would not reverse the array, else you get assignment problems if the length changes.
 
Here'as one possible alternative, showing both how to make a -1, 1 array and a bit representation of it.
 
 
 
 
Message Edited by altenbach on 04-06-2010 12:28 PM
Message 7 of 11
(3,231 Views)

Ravens Fan wrote:
You can remove the For Loop from around your step 3 and the code will still work.

Not with that equality to a floating point it won't. Smiley Wink

 

Do I have another nickel in my retirement fund?  Looks like I made a dime today!

Message 8 of 11
(3,215 Views)

smercurio_fc wrote:

Ravens Fan wrote:
You can remove the For Loop from around your step 3 and the code will still work.

Not with that equality to a floating point it won't. Smiley Wink

 

Do I have another nickel in my retirement fund?  Looks like I made a dime today!


 

True, but that's a different problem.  I was going for the "don't need to loop through something when the operator also operates on arrays" point.  🙂
Message 9 of 11
(3,208 Views)

I think scanning a 1 digit integer into a DBL is probably safe here, loop or not. Equality problems only occur with non-integers and results of computations.

 

Still, the DBL array allocates 8x more memory than needed to solve the problem.

Message 10 of 11
(3,207 Views)