From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

string to string array

Solved!
Go to solution

Hi everyone , thanks for your time .

I have saved in a file data like this :

name     address     phone        e-mail     , etc  

Each field separated with a tab (\t) delimiter .

I read each line of the file with read text file function and checking read lines , then use index string array , the result is :  each while iteration i can get the complete line of text (string) , i want to convert this string with tab separated fields into a string array .

Example :

 

input string (name    address     phone    e-mail)

 

output array of string elements :    name

                                                             address

                                                             phone

                                                             e-mail

 

Thank you all , i will appreciate any help .

 

 

 

0 Kudos
Message 1 of 9
(20,466 Views)

Tab-separated files are precisely the default file type of LabVIEW's Read/Write Spreadsheet (or Read/Write Delimited) File functions.  They can also read comma-separated Variable (.csv) files, which some mistakenly call "Excel" files.

 

If you use this Read function, you will create a 2D array, where each row corresponds to a line of your file, and each column to a tab-separated entry.  Note that since this is a 2D array, each "row" needs to have the same number of "columns", but it sounds like your data may fit this well.

 

If you need everything as one long array, use the Reshape Array function.

 

Bob Schor

0 Kudos
Message 2 of 9
(20,458 Views)

thanks for your time friend .

Here it is what i tried to accomplish , but i can't change the data type from double to string , do you know how can i do this ?

 

Captura.PNG

 

thank you very much for your help i really appreciate that .

0 Kudos
Message 3 of 9
(20,439 Views)
Please take the time for some of the free tutorials and always have context help open. You are using the wrong delimiter and with the DBL array constant, you are telling it to convert to that.
0 Kudos
Message 4 of 9
(20,430 Views)
thanks for your answer. I always use the context help but in this case I can't find how to change the array constant to a string type, the function has a tab delimiter by default why do you say it is wrong? thanks again
0 Kudos
Message 5 of 9
(20,418 Views)
Sorry, the default delimiter is a tab so that's okay.
0 Kudos
Message 6 of 9
(20,416 Views)
Solution
Accepted by topic author MaxiBarac

get an array constant and create an array of string then you can change your output data type.

Message 7 of 9
(20,401 Views)

it worked like a charm , thank you very much !!

0 Kudos
Message 8 of 9
(20,391 Views)

Once you have a String Array (the first step in your code), simply wire the Array into the Write Spreadsheet File function!  Don't make things more complicated than they need to be.

 

How much time/classes/tutorials have you invested in learning LabVIEW?  If you are doing it "on your own", you really should do as many of the Tutorials mentioned in the upper right corner of the Forum as you can.  It won't take but a few hours, and will give you a reasonable background and introduction to many aspects of LabVIEW.

 

Bob Schor

0 Kudos
Message 9 of 9
(20,385 Views)