LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare date and time between two text files

Solved!
Go to solution

Hello everybody,

It's the first time I publish a question on the forum but I don't find any answer on internet.

I have Labview 2019.

My aim is to compare two text files.

         First file (date time; value 1;value 2;value 3)

         Second file (date time; value 4;value 5;value 6)

I want to create a new text file

         New one (date time;value 1;value 2;value 3;value 4;value 5;value 6)

The following  VI works for few amount of data. But I may have  more than 10000 values.

I join you my VI.

You need to enter on the first file link the HOBO file and on the second the RBR file and change the enum to RBR.

If I am not clear tell me.

PS: I know my VI is not very clean.

 

Thanks a lot,

Adrien Bonnefoy

 

0 Kudos
Message 1 of 5
(897 Views)

Your code is hard to read; it's bigger than my monitor.

 

It's not clear what you want to do.

 

From the HOBO-2 File:

Titre de tracÈ : 20794806;;;
Date;ConductiviteLR;ConductiviteHR;Temperature
08/07/2022 05:30:00;0.9;0.8;22.51
08/07/2022 05:30:07;1;0.8;22.52
08/07/2022 05:30:08;2.3;0.8;22.52
08/07/2022 05:30:09;1;0.8;22.52

 

From the RBR-2 file:

Time;Pressure;Sea pressure;Depth
08/07/2022 05:30:00;10.19203465;0.059534648;0.059049164
08/07/2022 05:30:01;10.19192678;0.059426776;0.058942172
08/07/2022 05:30:02;10.19180169;0.059301695;0.058818111
08/07/2022 05:30:03;10.19187774;0.059377743;0.058893539
08/07/2022 05:30:04;10.191966;0.059466002;0.058981078
08/07/2022 05:30:05;10.19213271;0.059632713;0.059146429
08/07/2022 05:30:06;10.19243672;0.059936715;0.059447953
08/07/2022 05:30:07;10.19204445;0.059544454;0.05905889

 

It looks like RBR has time every second, but HOBO has gaps.

What do you want to do with those gap cases: where one file has data at 5:30:01 and the other doesn't?

I presume you need to time-align the data.

 

If that is correct, then

 

Open both files

Skip header line(s)

Create Result file.

 

repeat

   Read line from HOBO

   Convert column 0 to TIMESTAMP  (Th)

   Read line from RBR

   Convert column 0 to TIMESTAMP  (Tr)

   Repeat

       If Th < Tr

            Read Line from HOBO  

            Convert column 0 to TIMESTAMP  (Th)

       if Th > Tr

            Read line from RBR

            Convert column 0 to TIMESTAMP  (Tr)

       until (Th = Tr) or EOF

       if not EOF

           Extract Columns from HOBO and RBR lines

           Format new RESULT line

       end

until EOF

 

That will skip unmatched lines (in your example, that would be 5:30:01 to 5:30:06)

   

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 5
(868 Views)
Solution
Accepted by topic author adri73

Hello,

 

You were not far from succeeding.

Here is a cleaner, working solution that better uses loops, clusters and arrays.

Well actually that could almost be a CLD exercise 😉

 

Cordialement,

Raphaël.

0 Kudos
Message 3 of 5
(857 Views)

Hi guys,

Thanks for your quick answer.

I will look at your solution as soon as possible.

 

I know my code is very well constructed but I am a beginner with Labview (2 years).

I will let you know when I will succeed.

 

Adrien

 

0 Kudos
Message 4 of 5
(839 Views)

Hi Raphael,

 

I would like to thank you. I upgrade the code that ou sent to me, to match with my need and it's work very well.

I will try for my next code to make them more cleaner.

 

Best regards,

Adrien

0 Kudos
Message 5 of 5
(778 Views)