LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to seperate a string with multiple delimitors

I am setting up a DAQ system, first time working with LabVIEW. One of the instruments has a long string of data, multiple lines, multiple delimitors, including multiple delimitors in a row (ex. \t\s\s\s...). It is set up to be placed into a spreadsheet via Hyperterminal, but I want to use LabVIEW and arrays. Let me know if this sounds doable. Thanks
0 Kudos
Message 1 of 20
(3,393 Views)
Text parsing is incredibly easy in LabVIEW.

My suggestion, if you have multiple delimiters, is to use the "search and replace" function to replace all but a tab or comma, and then just send it to a text file (save yourself the conversion to numbers, and then back to text again, which is how spreadsheet files work anyway.)
Message 2 of 20
(3,393 Views)
Like Labviewguru said.

Also note:
The "\s" is generally a space and not a delimter.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 20
(3,393 Views)
If you can post a specific example of what the instrument returns I could give you some specific advice, and some example code.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 20
(3,393 Views)
Hey everyone,
Thanks for the replies. I'm including a string from the instrument and that way you guys can see it. The initial response from the guru is what I'm working on now. Thanks for the continuous help.

String:
8/1/2002 11:23 2s 30 secs. 2.00 Hz 60 Hz 70 Hz 1 6430
0.6 30 30 6430.6 6430.6 6430.6 0 29.05 0 999
800 2008800 6430.6 30 30 6430.6 6430.6
0.64 0 999800 2008800 6430.6 30 30 6430.6 6430.6 6

and this is how it looks with the delimitor symbols:

8/1/2002\s11:23\t\s\s\s\s\s\s2s\t30\ssecs.\t\s2.00\sHz\t\s\s\s60\sHz\t\s\s\s70\sHz\t1\t6430\t\t\n0.6\t30\t30\t6430.6\t6430.6\t6430.6\t0\t29.05\t0\t999\n800\t2008800\t6430.6\t30\t30\t6430.6\t6430.6\t\t\t\n0.64\t0\t999800\t2008800\t6430.6\t30\t30\t6430.6\t6430.6\t6
0 Kudos
Message 5 of 20
(3,393 Views)
ok couple of things. I think I am getting something confused. In order to seperate the string into the correct columns in the excel file, I used the pipe character (|) since this is the delimitor used in the instrument guide. However, this does not show up on the data received through the serial port, but does serve as the proper delimiter in excel. In the example I've shown here all I have are the tab and space "delimiters", which really can't be considered delimiters when using the search and replace function?
0 Kudos
Message 6 of 20
(3,393 Views)
I was able to use the function, I used it twice, once to remove spaces and once to remove new lines. This creates one long string. If the number positions remain constant, I can use a function with an offset to seperate out the numbers. But I'm pretty sure the number values are dynamic. Hence, I was thinking of a loop which eliminates spaces one at a time, as long as that space is followed by another space. As soon as this condition is false, the function searches on until the next occurance of /s/s... Or, a loop which simply looks for numbers followed by spaces and seperates each into an own position in a 1D array. Not sure how to do either though, whether it would be a slow loop, or if this automatically deals with /t and /n. Let me know what you thin
k
0 Kudos
Message 7 of 20
(3,393 Views)
Based on your example, I would advise that you don't worry about the spaces, they don't appear to be delimiters, but padding for fixed-length fields.

Simply use the spreadsheet string to array converted function with a tab delimiter, then process each row based on the data in it. You shouldn't have to worry about the leading spaces as the functions for converting strings into numbers are smart enough to ignore leading spaces...and trailing ones as well (see attached exceedingly trivial example).

Piece o' cake...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 20
(3,267 Views)
mike, your example works using spreadsheet string to array function, but it only takes the first number from each row giving me a 1x4 array:
array = 8
.6
800
.64
Any suggestions on what's causing this, should I be running a loop?
0 Kudos
Message 9 of 20
(3,267 Views)
The tab character is considered a valid delimiter for spreadsheets. The spaces can probably be ingored.

Could you please attach a text file of the original data, and then a spreadsheet file (either excel 97, or text with tab delimiting) of the results you are looking for. I can better assist you if I have the input and output. This sounds like it may be a complex parsing, with a simple solution. Describing the problem and trying to offer a solution may be much more difficult without the data itself. You did provide the original string here, but that doesn't help me without the reults you are looking for.

Thanks
0 Kudos
Message 10 of 20
(3,393 Views)