ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

spreadsheet string to array function - what am I doing wrong?

Solved!
Go to solution

I'm trying to utilize a hard coded spreadsheet in the VI below and allow the user to select which row of the value to call out. Trouble is that the program is not able to read the value at any given row and would return a value of "0" no matter the rows selected.Spread sheet to array.png

0 Kudos
Message 1 of 15
(10,741 Views)

You need to change your format specifier from %d to %f.

 

However, you are making this way too complicated.

 

See below.

 

mcduff

snip.png

 

 

 

 

0 Kudos
Message 2 of 15
(10,729 Views)
  • You need to specify the comma delimiter. 
  • You should use a %f format string.  Otherwise values will be rounded. 
  • A 2d array is not necessary.  Wire up a 1D array to the array type input on Spreadsheet String to Array.
aputman
0 Kudos
Message 3 of 15
(10,728 Views)

@mcduff wrote:

However, you are making this way too complicated.


Depends on where the data is coming from. 

aputman
0 Kudos
Message 4 of 15
(10,725 Views)

1. Set your delimiter to be a comma (,).  The Spreadsheet String To Array defaults to use a tab.

2. You probably want to use %f as your format, which is for a floating point.  Write now you have %d, which is for an integer.  Therefore the scan currently ends at the period.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 15
(10,724 Views)

You need to specify the comma delimiter. 

 

Not needed in this case since there is a new line in between values, if it was all one line then yes. Parses correctly in LabVIEW 2017 without comma delimiter.

 

Main Problem %d specifier, not %f (There are other problems as you have noticed.)

 

cheers,

mcduff

0 Kudos
Message 6 of 15
(10,718 Views)

@aputman wrote:

@mcduff wrote:

However, you are making this way too complicated.


Depends on where the data is coming from. 


From the OP

a hard coded spreadsheet

 

Should be able to change that to an array of numbers Smiley Wink

 

mcduff

0 Kudos
Message 7 of 15
(10,715 Views)

@mcduff wrote:

@aputman wrote:

@mcduff wrote:

However, you are making this way too complicated.


Depends on where the data is coming from. 


From the OP

a hard coded spreadsheet

 

Should be able to change that to an array of numbers Smiley Wink

 

mcduff


I understood that statement completely different.  A string is not a "hardcoded spreadsheet".  Smiley Very Happy

aputman
0 Kudos
Message 8 of 15
(10,712 Views)

I have strange interpretations of words, sorry.

 

Hard coded to me meant it was stuck inside the code. (Also previously the OP posted a VI in another thread that had the same/similar VI as the one posted here throughout it. That may be biasing me a bit. They weren't reading from an instrument, file, etc.)

 

cheers,

mcduff

0 Kudos
Message 9 of 15
(10,700 Views)

wow you guys even went through my past questions, that's impressive.

But yes I am trying to in some way hard code the values as so users won't somehow alternate the given values unless purposely doing so.

0 Kudos
Message 10 of 15
(10,646 Views)