LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to separate each data in a given string and put it into table?

Hi. I am trying to do serial communication with a machine which send data for the given command. When command "d" is given i get response like

eg1. "d 1015 49.3 14.3 75.8      84.8 73.2 74.7 70.5" 

eg2. "d  720 47.6 12.9  108       110  113  101  107"

eg3. "d  700 45.0  7.4  105       105  108  101  108"

eg4. "d 1177 48.1  8.2  6.5       5.0  5.8 11.7  3.5"

The space between each data is varying. So, how to seperate these values and put it into table?

 

Thank you.

0 Kudos
Message 1 of 4
(3,222 Views)

Use the Search and Replace String function.  Set the flag to use Regular Expressions.  You can then set it up to replace multiple spaces with a single space.  Then use Spreadsheet String To Array with a space set to the delimiter to make your 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
Message 2 of 4
(3,214 Views)

Thank you crossrulz. This is very helpful. But sometimes second data after command will not be displayed,instead it shows blank space. This happens before machine stabilizes. In this time when i collected the data i got

" d  100      35.1  139       118  135  153  148"

"d  100      35.6  134       114  132  150  141"

"d  100      35.7  132       113  130  148  138"

After the machines stabilized i got these values 

"d  200  4.6  7.9 85.6      84.8 85.0 90.4 82.5"

"d  200  4.4  7.4 86.1      86.6 85.0 90.1 82.7"

"d  200  4.4  7.9 84.8      83.1 84.2 89.9 82.0"

So how to put zero in array for the data which i have not received. Should we compare number of blank spaces or is there any other logic ?

0 Kudos
Message 3 of 4
(3,169 Views)

How many fields (columns) are you expecting? Is it a set number, or does that change with time too? When an input is "stable" how many spaces are in between each? If it's not constant between each column, is it at least constistent, eg 1 space between first and second column, 3 spaces between second and third column, etc?

0 Kudos
Message 4 of 4
(3,142 Views)