06-11-2013 01:48 PM
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?
Solved! Go to Solution.
06-11-2013 02:04 PM - edited 06-11-2013 02:08 PM
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.)
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
06-11-2013 02:25 PM
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?
06-11-2013 02:46 PM
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.
06-11-2013 02:47 PM - edited 06-11-2013 02:56 PM
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
06-11-2013 03:12 PM
Yes. Figure 14 is the CSV file displayed in Excel.
06-11-2013 03:25 PM
Please find the attached actual code and CVS file.
06-11-2013 03:42 PM - edited 06-11-2013 03:45 PM
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?
06-11-2013 03:45 PM
Thank you