LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read tab-delimited text file and count the number of occurrences within specific dates

I have a tab-delimited text file, with Date, Time & Status(Pass/Fail) columns.

I need to count the number of occurrences of PASS or FAIL status items within the selected dates.

 

So, if I select Date from 01/01/2018 to 01/02/2018, then I should get the count of all the PASS & FAIL status within these dates.

 

I am using Labview version 17(Eval).

 

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

Do some (free) courses.

Read the file.

Convert columns to values (Timestamps and Booleans).

Use a Threshold function to find the time indices of the begin and end.

Use the begin and end indices to loop over the Boolean array and add if true.

 

Let us know what you've tried and where you failed...

0 Kudos
Message 2 of 9
(3,823 Views)

Thanks for the suggestion.

 

As you have figured out, that I am new to Labview.

 

I read the tab-delimited text file, and using index arrays, I managed to get the output in the form of strings. So I have the Date string, Time string & the Status string as individual elements.

Now , my question is, is there a way in Labview, to convert date-time values to timestamp value?

 

 

 

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

@depme wrote: 

I read the tab-delimited text file, and using index arrays, I managed to get the output in the form of strings. So I have the Date string, Time string & the Status string as individual elements.


I hope you're using Spreadsheet String To Array for that? At least look into it. 

 


@depme wrote:

 

Now , my question is, is there a way in Labview, to convert date-time values to timestamp value?

Scan From String does that. Click it's detailed help, and all the way at the bottom there is an example to scan a date\time string. You should use a format string like %<%H:%M:%S%2u%m/%d/%y>T.

 

The formatting is the same as Format Date\Time String (but it works in reverse). The help on Format Date\Time String is a bit more elaborate.

0 Kudos
Message 4 of 9
(3,782 Views)

Are the entries sorted by date?

Are all entries either PASS or FAIL or are there other conditions (blank, not measured, unknown, etc). How big is the file? How clean is the file? Is it computer generated or potentially edited by humans. Is the data format always exactly the same? Are there lines that don't have data (headers, separators, etc.)

 

So the inputs are "file name", "start date" and "end date" and the output is a single integer and an error status. Is that right?

 

 

0 Kudos
Message 5 of 9
(3,775 Views)

The data assumed is unsorted by date & is actually present in multiple tab-delimited files having multiple other columns.

 

For simplicity & for my Labview holds-on, I have saved all the data manually in a tab-delimited text file, and only taken Date, Time & Status columns, to start my Labview practical.

 

So, I have to read this file, then select "start date" and "end date", and then get the count of how many Passed & how many Failed. 

 

Attached is the data file in tab-delimited format.

0 Kudos
Message 6 of 9
(3,754 Views)

Ok, the unsorted date\time adds a factor of complexity.

 

Two ways to deal with it:

1) parse all rows and sort on date\time after converting it o a timestamp

2) Loop over all rows and check if the value is within the begin\end range. If so, add 1 if it passed.

 

1) Is probably a bit more intuitive and easier to debug. 2) Could be faster if the files get large. The entire file does not need to be read at once, the file can be read line by line, reducing the need for memory. That would get significant if the files get larger then several MB (1?, 10?, 100? how knows).

0 Kudos
Message 7 of 9
(3,741 Views)

Here's method 2. Method 1 would be very similar (the string parsing could be reused).

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

Thanks for the solution.

 It will certainly help.

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