06-25-2019 04:54 PM - edited 06-25-2019 05:03 PM
I am trying to parse data coming from a device(serial communication), the data is space delimited but the number of spaces are irregular. How can I make the number of spaces even so that I can extract the data I need into individual columns of an array for further processing?
If this is my original message; 118.0 DRAW 60 0 6 98 0 9 55 1952 3235 -12 -2 0 56 [ccOOccOc] 0 5640 0 0 0 [ffff]
119.0 DRAW 60 0 6 99 0 9 57 1952 3235 -12 -2 0 57 [ccOOccOc] 0 5640 0 0 0 [ffff]
120.0 DRAW 60 0 6 100 0 9 58 1952 3235 -12 -2 0 58 [ccOOccOc] 0 5640 0 0 0 [ffff]
121.0 DRAW 60 0 6 101 0 10 58 1952 3235 -12 -2 0 59 [ccOOccOc] 0 5640 0 0 0 [ffff]
how do I make it like this with equal spacing,
118.0 DRAW 60 0 6 98 0 9 55 1952 3235 -12 -2 0 56 [ccOOccOc] 0 5640 0 0 0 [ffff]
119.0 DRAW 60 0 6 99 0 9 57 1952 3235 -12 -2 0 57 [ccOOccOc] 0 5640 0 0 0 [ffff]
120.0 DRAW 60 0 6 100 0 9 58 1952 3235 -12 -2 0 58 [ccOOccOc] 0 5640 0 0 0 [ffff]
121.0 DRAW 60 0 6 101 0 10 58 1952 3235 -12 -2 0 59 [ccOOccOc] 0 5640 0 0 0 [ffff]
Also if the device has different substates, how can I detect using a boolean when the device enters and exits a particular substate?
Solved! Go to Solution.
06-25-2019 05:42 PM - edited 06-25-2019 05:44 PM
I don't understand. The two text examples are identical.
I also have no idea what you mean by "substates".
06-25-2019 05:51 PM
I am new to labview, my question may be pretty basic. Sorry for the confusion though.
So there are multiple lines being received through the serial data and I am trying to parse them into individual columns using a space delimiter as that is how it is being sent by the device. Some of the columns have single space which fall into the right array columns, but for the ones with extra white spaces leave gaps in the array. I am trying to even the spaces so it would be easy for me to parse the data.
06-25-2019 09:58 PM
You could do a search and replace on our string and replace any instance of two consecutive spaces with just one. Keep repeating until you find no more instances. The spreadsheet string to array using space as the delimiter.
06-26-2019 02:26 AM
@LVPS28 wrote:
I am new to labview, my question may be pretty basic. Sorry for the confusion though.
So there are multiple lines being received through the serial data and I am trying to parse them into individual columns using a space delimiter as that is how it is being sent by the device. Some of the columns have single space which fall into the right array columns, but for the ones with extra white spaces leave gaps in the array. I am trying to even the spaces so it would be easy for me to parse the data.
Oh, it's just that the "unconverted" data was identical to the "converted" data, and it confused me. Or it seemed that way when I placed them into a monospaced editor.
06-26-2019 03:49 AM
Try this and see if you can use it.
/Peter
06-26-2019 09:54 AM - edited 06-26-2019 10:00 AM
Thank you Peter, this helps for my application.
06-26-2019 10:00 AM - edited 06-26-2019 10:01 AM
Sorry about that Bill!
When I meant states I am trying to find a particular string from a file and detect by enabling a boolean when found and disabling the boolean when not found.
Thanks!
06-26-2019 11:22 AM
@LVPS28 wrote:
Sorry about that Bill!
When I meant states I am trying to find a particular string from a file and detect by enabling a boolean when found and disabling the boolean when not found.
Thanks!
🙂