LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting rows from csv

Alright so this might be a bit confusing, I'm trying to avoid using python but I may not have a choice here. 

To give some background this is for logging test shots at a ballistics facility and I need a count of how many of each projectile was shot, amount of powder used for each type of propellant. 

 

I have user inputs being saved to a CSV every time they click the save button. 

At the end of the day, they have to have a total count for resources used in testing (which is what is recorded each time the save button is pressed).

 

So I want to create a case where they can press a calculate button and it will filter through the CSV and only extract the rows of data for that day. 

I've already cut the date-time stamp down to just the day I'm just not sure how to go through and get the rows based on that.

 

Once I get that it needs to be filtered more based on other things, but whatever I do to filter based on the date I'll do that on each subset of data. 

 

0 Kudos
Message 1 of 9
(3,797 Views)

Post your code so we can help guide you through the rest of what you are trying to accomplish. It is hard to tell you what to do without seeing how you did it. Having a file similar to what you are trying to filter would also be a great idea.

Tim
GHSP
0 Kudos
Message 2 of 9
(3,786 Views)

I started writing the python script so I don't have any code written for this particular case yet. I can post what I have. Can I upload a VI? or can it be a screenshot?

0 Kudos
Message 3 of 9
(3,781 Views)

Code is usually better. To open a file in LabVIEW is very easy. Look at the example files to see how to do this. Make a vi that will open your data and display it in an indicator. Do you have a data file that you can share?

Tim
GHSP
0 Kudos
Message 4 of 9
(3,774 Views)

I attached the main.vi, you shouldn't need the other vi to run it.

Download All
0 Kudos
Message 5 of 9
(3,761 Views)

Not sure, but maybe you're looking for something like this:

csvd.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 6 of 9
(3,747 Views)

What format is the date time in? 49:50.1 is not something I am familiar with. Once you get a common format for your data I would simply use an in range vi to check if the dates are within a the min and max for the date. If it is add it to an array if not don't.

 

Next step would be to figure out which fields (columns) you want to sum and report that how ever you want to.

 

See the picture for a hint.

 

Date Function.png

You would pass your array of data to this and then sum the fields if they are in range.

Tim
GHSP
0 Kudos
Message 7 of 9
(3,745 Views)

The only issue with that is, the data is stored as a string in a CSV. Would you use a regular expression to parse the cell (row of data) if so then how do you select the rows once it matches up?

0 Kudos
Message 8 of 9
(3,733 Views)

Hi Russ,

 

Paul has shown you how to convert a string to a timestamp value.

Converting to "default" numeric values works the same way.

(No need for RegEx…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 9
(3,670 Views)