LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String to Array

I have a string of data elements separated by commas. I need each data reading to become one row of an array. So I am trying to get data that looks like this:

36, 36, 36, 36, 36

To look like this

36
36
36
36

I tried to use a while loop but when I tried to change the wire connections to Shift Registers, the loop doesn't like that one of the end point is an array. I have a pattern repeating for 5 data points and I get the data to look like I want it to but this cannot work if I want to have 2500 readings because then I would have to repeat the pattern 2500 times and there just seems to be a better way to approach this. I have attached the VI and data file.

The VI is in 7.1 but I have access to 8.2 on another machine so feel free to send that any help in either version. Thanks!






0 Kudos
Message 1 of 8
(3,135 Views)

You could use "spreadheet string to array" with a comma as delimiter and read your data into a 1D array of numbers. One step! 😄

 

btw, can you explain the reason for your while loop? It just calculates the same thing over and over, consuming all CPU until stop is pressed. I think you can leave that out.



Message Edited by altenbach on 02-15-2008 06:13 PM
0 Kudos
Message 2 of 8
(3,134 Views)
I did use that Spreadsheet to 1D array and I get a bogus data file. It reads like chinese.
0 Kudos
Message 3 of 8
(3,117 Views)

Hi esalas

it works fine like altenbach said.

Mike

0 Kudos
Message 4 of 8
(3,114 Views)
I originally setup the VI to call voltage, amps, and a timestap per reading. This is what the data looked like:

1.72 V, 1 A, 1s, 1.72 V, 1 A, 2 s, 1.73 V, 1 A, 3 s

Then I wanted to take this string and make three different strings, using the match pattern icon, so it would look like this:

1.72 V, 1.72 V, 1.73 V

1 A, 1 A, 1 A

1 s, 2 s, 3 s

I used the spreadsheet to array icon and I get a data file that looks like this, without a while loop. I basically feed the string from the read into the spreadsheet to array and the data file it spitted out looked like chinese, I've attached the data file.

The following is what is attached:

1st VI - I know there is a problem with the shift register because I haven't set it but then it won't allow me to put the array data in the write file icon.
2nd VI  - Gives me chicken scratch
Text File - My chicken scratch
0 Kudos
Message 5 of 8
(3,061 Views)
Hi esalas,

your vi looks like talking to a Keithley DMM. You surely can change the output format of the DMM to either remove the space between value and unit or omit the unit at all.
I also recall an output format of the Keithley DMM with just number separated by commas...

All of these will make parsing the string much easier as you don't have to remove unneccessary chars/spaces!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 8
(3,059 Views)
Hi esalas,

the attached vi is easily converting your string to an array of strings using comma as separator.
It's up to you to convert it to a 2d arraySmiley Wink
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(3,057 Views)
esalas,
 
The biggest mistake you made in the VI with the Spreadsheet String to Array function is that you chose the datatype to be a 2D array of dbl. If you wanted the file to be text, you should have chosen a string array data type.
0 Kudos
Message 8 of 8
(3,042 Views)