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: 

How to extract useful data from comma separated string

Hi, 

I have a result which is a comma separated string (please see the attachment). 

I need to extract some useful data in the middle (from 0.100, 4 to 5.000,0) for summation operation. 

I am trying to use the "scan from string" function to extract them, but I don't know what format string to use. 

 

Any help will be highly appreciated. 

Bingji

0 Kudos
Message 1 of 13
(5,349 Views)

Hi, 

I have a result which is a comma separated string (please see the attachment). 

I need to extract some useful data in the middle (from 0.100, 4 to 5.000,0) for summation operation. 

I am trying to use the "scan from string" function to extract them, but I don't know what format string to use. 

 

Any help will be highly appreciated. 

Bingji

Download All
0 Kudos
Message 2 of 13
(5,350 Views)

There is different ways that can be done.  Ive got a few questions thatll help to decide the best method.

 

1. Is the data always going to be the same as you show there?

2. Is the data always going to be in the same location according to the csv format?

3. Can you provide the raw data?



-Matt
0 Kudos
Message 3 of 13
(5,342 Views)

I would place the data into an array using Spreadsheet String to Array and then use your values to work off that array.

Message 4 of 13
(5,344 Views)

Hi, Wolleee

 

Thanks for the quick reply.  Here is the answers to your questions.

1. Is the data always going to be the same as you show there?

It won't be exactly same as I showed here. The only difference should be the values after 0.100, 0.150, 0.200, 0.250,0.300, 0.500, 1.000 and 5.000. Also the date and time value should be different as well.

2. Is the data always going to be in the same location according to the csv format?

Yes. All the data is always going to be in the same location of the CSV format.

3. Can you provide the raw data?

This is raw data. This is the testing results of my particle counter.

0.100 is the smallest particle size. And the number after 0.100 is the particle amount for this size range.

5.000 is the largest particle size. And the number after 5.000 is the particle count for this size range.

What I need to do is to add all the particle count in different size range together after each testing.

 

Thanks for your help.

 

Bingji

0 Kudos
Message 6 of 13
(5,332 Views)

thanks for pointing out. It is an accident for double posting.

Sorry about that.

0 Kudos
Message 7 of 13
(5,323 Views)

No worries.

Do us a favor and upload your VI (not images like JPGs) and we can give suggestions on that. A VI can tell us more than a image can.

0 Kudos
Message 8 of 13
(5,319 Views)

Scan from Strings is a wonderful function, but it can be complicated if you mix text and numeric data.  On the other hand, you can do a "comma search" and use it to break your string into "Everything before the comma" and "Everything from the comma onward".  "So what?", you say.  Well, Everything Before is part of what you want, and if you take the comma off from "Everything from Comma onward", what you have is "something smaller that's the same as your original problem", something that a mathematician would call a "recursive problem".  This is easily solved using a While Loop, a Shift Register to hold the input string and "Everything after the comma", and an indexing tunnel to build the "Everything before the comma" into an Array of Strings.

 

We now have a simpler sub-problem -- how to turn Everything from Comma onward" to "Everything after the Comma".  There is no explicit "Delete string", but you can "fake it" with another String Function (left as an exercise to the Reader -- you do want to learn LabVIEW, don't you?).

 

Now, if you'd provided code, I'd probably have returned a Snippet for you.  But if you follow the steps above, you'll probably learn even more by doing it yourself!

 

Bob Schor

0 Kudos
Message 9 of 13
(5,285 Views)

Since the data is always in the same location, i would simply use the spreadsheet string to array and then pull the array subset that you are looking.



-Matt
0 Kudos
Message 10 of 13
(5,271 Views)