LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I split a string in a string array into separate arrays

Solved!
Go to solution

Greetings,

 

I have a string array which is displaying strings from a text file. I read each line of the text file and put it into an element of the string array.

 

Now I am trying to split each string to then put each part of the string into a separate array. Each element in the string is separated by a comma. I have hit a brick wall at this stage and would like some help please?

 

The purpose of this is so that I will have 4 arrays which I will ready their element values and set  variables according to those values until I have gone through all the elements in each array. 

 

Example attached.

Also my VI is attached.

 

Thank you in advance for your help.

 

 

 

Download All
0 Kudos
Message 1 of 14
(8,804 Views)

Hi! 

I can't open your VI, because I have the 2012 LabView version... but if you have a comma seperated values, you can use the Read from spreadsheet file VI. 

0 Kudos
Message 2 of 14
(8,795 Views)

Hi AdamTrojak,

 

Apologies, please find attached.

 

Thank you

0 Kudos
Message 3 of 14
(8,782 Views)

You could just use Read From Spreadsheet File to read the 2D array of strings.  Just make sure you set the delimiter to be a comma.  Alternatively, you could just read the entire file as a string and then use Spreadsheet String To Array to make the 2D array.  This will have a little less overhead than the Read From Speadsheet File.


GCentral
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 4 of 14
(8,777 Views)

Hi crossrulz,

 

I begin with an array of strings from this array I create 4 more arrays holding the values from one string element i.e suppose one element in the string array is [F,1,2,3]...

the F must go to one array, the 1 to another array, the 2 to another array and the 3 to another array. Therefore, if I have a string array with [F,1,2,3] [B,3,2,1] each of the 4 arrays will have two elements in them i.e Array1 [F] [B] Array2 [1] [3] Array3 [2] [2] Array4 [3] [1].

 

I hope this makes sense or I have misunderstood your reply.

 

Thank you.

0 Kudos
Message 5 of 14
(8,759 Views)

Very similar to this but instead of two arrays, I require four.

0 Kudos
Message 6 of 14
(8,749 Views)
Solution
Accepted by topic author stanm13

Then just use Index Array on the supplied 2D array.


GCentral
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 7 of 14
(8,730 Views)

Yes, I understand now.

 

How do you get the array type of Spreadsheet String to Array to be string, I am getting Double.

 

Thank you.

0 Kudos
Message 8 of 14
(8,720 Views)

@stanm13 wrote:

Yes, I understand now.

 

How do you get the array type of Spreadsheet String to Array to be string, I am getting Double.

 

Thank you.


Make a constant that is a 2D Array of string and wire it into the type input.


GCentral
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
Message 9 of 14
(8,702 Views)

crossrulz,

 

Thank you for the help thus far.

 

I am very close to my solution.

 

image1 shows my current results

image2 shows what I am trying to achieve 

 

If I do it the second (image2) way then I always have a fixed number of Arrays (4) - Array1, Array2, Array3 and Array4. Therefore all corresponding values are stored in the correct array.

Download All
0 Kudos
Message 10 of 14
(8,679 Views)