03-18-2016 06:39 AM
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.
Solved! Go to Solution.
03-18-2016 06:43 AM
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.
03-18-2016 06:50 AM
Hi AdamTrojak,
Apologies, please find attached.
Thank you
03-18-2016 06:52 AM - edited 03-18-2016 06:53 AM
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.
03-18-2016 07:03 AM
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.
03-18-2016 07:08 AM
Very similar to this but instead of two arrays, I require four.
03-18-2016 07:41 AM - edited 03-18-2016 07:41 AM
Then just use Index Array on the supplied 2D array.
03-18-2016 07:47 AM
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.
03-18-2016 08:00 AM
@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.
03-18-2016 08:47 AM
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.