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 do I read 2 CSV files of line by line match/compare and if no match flag and display error with location of error?

Solved!
Go to solution

I’m new in LabVIEW and have searched for any examples of what I’m trying to accomplish with no luck and I seriously need some help!! How do I read 2 CSV files line by line match/compare and if no match flag and display error with location of the error? My files have over 1000 lines. I have attached a flow chart to reflect what I’m trying to achieve.

0 Kudos
Message 1 of 20
(3,416 Views)

Read both files simultaneously in a loop a line at a time.  Compare the strings.  If they are not equal, stop the loop, display the strings.  By reading the i terminal of the loop, you'll know which line of the file it stopped at.

0 Kudos
Message 2 of 20
(3,412 Views)

compare the 2 arrays in a for loop and build an array for the location...

 

Spoiler
compare arrays mismatch.png

 

0 Kudos
Message 3 of 20
(3,404 Views)

@apok wrote:

compare the 2 arrays in a for loop and build an array for the location...

 

Spoiler
compare arrays mismatch.png

 



You don't even need the FOR loop.  Do the comparison on the arrays of lines and perform a Search 1D Array on the boolean for a False (assuming using Equal).  It will return the index of the first line that was different and a -1 if they lines were the same.


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
0 Kudos
Message 4 of 20
(3,381 Views)

None of the above post works. Maybe misunderstood. The idea is to read each line from the file and compare to a corresponding line (known results) and if they match flag a pass/fail. Need to do this sequencially my files have strings stored in a 1D array as csv file. Any help is really appreciated and thank you.

 

Like

 

file1   file2   results
This is a stop sign This is a stop sign pass
Cross walk stop   Fail

 

 

0 Kudos
Message 5 of 20
(3,357 Views)

Attach your VI and your example files.

 

I'm sure it will work.  It must be something in your implementation.

0 Kudos
Message 6 of 20
(3,355 Views)
Solution
Accepted by topic author Maskan

Example_VI.png

Message 7 of 20
(3,350 Views)

That is a screenshot, not a VI.

 

So what is wrong with what is attached?

 

It looks like you have the array broken up into words rather than lines.  In which case the problem is where you read in the data file and created an array out of that.

 

Since you didn't attach a VI that shows that part of your operation, I can't comment on that.

0 Kudos
Message 8 of 20
(3,346 Views)

@RavensFan wrote:

That is a screenshot, not a VI.

 

So what is wrong with what is attached?

 

It looks like you have the array broken up into words rather than lines.  In which case the problem is where you read in the data file and created an array out of that.

 

Since you didn't attach a VI that shows that part of your operation, I can't comment on that.


Ravens: Different posters.
OP: APOK has the solution right there for you.

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
0 Kudos
Message 9 of 20
(3,336 Views)

crossrulz wrote:Ravens: Different posters.
OP: APOK has the solution right there for you.

You're right!  I must have merged a couple of posts together in my mind when I read them.

 

But the part about an array of words vs.an array of lines still applies.

0 Kudos
Message 10 of 20
(3,330 Views)