LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using spreadsheet function to convert string to 1d array

Solved!
Go to solution

Hello 2 all !

 

I have the following problem : i have a string (which i read from a txt file), and using spreadsheet string to array function, i want to transform this string into a 1d array of double. MY PROBLEM is that the result string has only the first element. How can i see the other elements too ?

 

Thank you 4 your time !

 

P.S. I'm using LabView 8.5.1. on Windows XP SP 2

Download All
0 Kudos
Message 1 of 51
(17,322 Views)
Your delimiter on your spreadsheet to array is defaulted to tab. You need to change it to \n.
PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 2 of 51
(17,303 Views)

Thank you Paul G. That was a pertinent observation.

However, the 1d array still contains only 1 element.

0 Kudos
Message 3 of 51
(17,296 Views)

If you typed in \n into a constant you will have an extra backslash. Change the view of the constant to '\'codes display and you will see two backslashes. Just delete one of them.

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 4 of 51
(17,291 Views)
Solution
Accepted by topic author AndreiN2014

Check the code below:

 

 

 

 

or solution only:  (not sure why Path2 showed up...  ignore it..)

 

Message Edited by Ray.R on 01-06-2010 08:12 AM
Download All
Message 5 of 51
(17,286 Views)
Yes. You are rigth. It works. Thank you very much 4 your time !:smileyhappy:
0 Kudos
Message 6 of 51
(17,285 Views)

YOU CHANGED HIS CODE! Smiley Surprised But simpler is always better. Smiley Happy Kudos.

PaulG.

LabVIEW versions 5.0 - 2020

“All programmers are optimists”
― Frederick P. Brooks Jr.
Message 7 of 51
(17,268 Views)
You have 3 kudoses from me PaulG. Thank you again four your time !
0 Kudos
Message 8 of 51
(17,257 Views)

Hi Ray,

 

your solution is maybe "nicer" (it uses only one wrapper function from vi.lib) - but it is not the same!

 

The original version will pad using NaNs (instead of zeros from ReadFromSpreadsheet). This could be important and might change final results...

It's also more easy to change for personal needs (like using different prompts). So the only thing needed was to add the correct delimiter...

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 51
(17,255 Views)

Good call GerdW,

 

I looked at the text file and made the assumption that it would be all numeric followed by a new line, which is why I simplified the solution.  

 


GerdW wrote:

The original version will pad using NaNs (instead of zeros from ReadFromSpreadsheet). This could be important and might change final results...

 

Are you sure?  Because I added "hello" as part of the data (right after '6'), and in both versions it placed 0 in the array. See image below:

 

 

 

Message Edited by Ray.R on 01-06-2010 08:51 AM
Message 10 of 51
(17,244 Views)