LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Spreadsheet String To Array.vi with negative numbers

Solved!
Go to solution

I was exploring a program posted on the developer zone entitled " ClipboardtoNumericArray.vi" and noticed that it substituted 0 for elements with negative numbers. Does the " Spreadsheet String To Array.vi" work with negative numbers? If so, how?

0 Kudos
Message 1 of 9
(4,580 Views)

Yes it also works with negative numbers, in fact you can also specify what number representation you want in the output array by making appropriate connection to "array type" input on the lower left-hand side as shown in attached image (you'd also have to specify an appropriate "format string" above it.)

 

Untitled.png

 

 

But I don't see this vi substituting any negative numbers with 0, where do you see it?

 

(Perhaps the vi you saw was made for unsigned numbers and in which case vi could have been designed to set any negative numbers in strings to 0 before using Spreadsheet String To Array.vi.)

 

-DP

 

 

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 2 of 9
(4,573 Views)

I up loaded the CSV file and program that I used. Please find the attached Figure 14 that displays my copy to clipboard from the CSV file and Figure 13 that displays what the "ClipboardtoNumericArray.vi" captured. Assuming zero for the first column or row, look at column-5 and row-0 through row-5 in Figure 14 and Figure 13. The element source is negative and the result is zero. Why?

Download All
0 Kudos
Message 3 of 9
(4,560 Views)

Is figure 14 a screenshot from Excel?

 

If so, it looks like they cells with negative values are formatted as text because they are left aligned.  Which is why it might be interpreted as 0.  While the other numbers are all right aligned as they would be if Excel thinks of them as numbers.

0 Kudos
Message 4 of 9
(4,530 Views)

Everything looks fine to me, must be something else in your software causing the issue- see attached file. (I used excel to try this out - I formatted some data as text and right justified, but it still gave me correct result - so that doesn't seem to be the case here. In fact in excel I also made some values as text and left others as numbers and I still got correct result.. second image/column 0/values in rows 2 and 3 are text.)

 

Can't offer any further help since you have not posted your actual code.

 

-DP

 

Untitled.png

 

Untitled.png

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 5 of 9
(4,529 Views)

Yes. Figure 14 is the CSV file displayed in Excel.

0 Kudos
Message 6 of 9
(4,513 Views)

Please find the attached actual code and CVS file.

Download All
0 Kudos
Message 7 of 9
(4,501 Views)
Solution
Accepted by topic author Ed___

The problem is that your negative sign is not a negative sign.  It is ASCII code 150.  I'll call it something like a "long dash", which is why the LabVIEW code doesn't recognize it.  A real negative sign like you have in the E-6 part is ASCII code 45.  And also why even Excel treats it as text rather than a number.

 

Where did you get the CSV file from?

0 Kudos
Message 8 of 9
(4,491 Views)

Thank you

0 Kudos
Message 9 of 9
(4,483 Views)