LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Log in with data read from an excel csv file

Solved!
Go to solution

Hello,

I am a student and I am doing my master's thesis. I want to include a program where people can register and that registration goes to an excel .csv file and then they are able to log in.
The goal is for the person to enter the ID and password and the program will see if it exists in the database, if it exists opens a menu, otherwise it will show an error message.
The problem I'm having is that to get out of the FOR cycle (red circle) I have to put something for the true/false. Can you help me?

 

Best Regards,

 

InêsDúvida.png

0 Kudos
Message 1 of 6
(1,362 Views)

Let's state your question in a different way.

 

You have an array of usernames and passwords you want to compare the entered username and password.   If anyone of them is true, then you wan the True case of the case structure to run.  Your comparison mode of the array should be Compare Aggregates.    From the picture, it looks like you have it set to Compare Elements.  That way you get a single boolean whether both elements or true or not. 

 

If you turn that tunnel into Concatenate Mode, then you'll get a 1-D array of booleans.  If you do OR Array Elements, and wire that to the Case Selector, if you ever find a True among that list, the True case will run.

 

If you have a relatively newer version of LabVIEW, then there is a better option.  You can stop the comparisons once you find the first True.  Right click on the For Loop and Enable the Conditional Terminal.  Wire the output of the Equals to that.  The loop will then stop early once it finds a true.  Feed that boolean out with the regular tunnel and wire it to the case structure because the last value will be True if it stops early, or False if it never found a match.

0 Kudos
Message 2 of 6
(1,340 Views)

I did that and it's not working ... I send you the program and the database document. Can you take a look, please?

 

Inês

0 Kudos
Message 3 of 6
(1,330 Views)

You don't have a "database document".  You have a CSV text file where your data is messy.  It has quotes and tab characters in it.  So according you your file, your username is "1234   and the password is tabliveandlove" as they are the two things between the commas.

 

Also, that subArray function serves no purpose but return the same array you started with.  It doesn't hurt anything, but doesn't help anything either.

 

Fix your CSV file and you'll be fine.

 

Also, sending us a VI that closes itself and has no means of aborting the VI or moving the window around while you are still in development is a real nuisance.  Luckily I have an Abort.VI that allows me to kill LabVIEW VI's that struck in running.

0 Kudos
Message 4 of 6
(1,316 Views)
Solution
Accepted by topic author inescruz32

Hi ines,

 

after cleaning up your CSV file it becomes quite easy to test for credentials:

(You better implement some more error checking…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(1,279 Views)

Hi GerdW,

 

Thank you for your help. My program works !

 

Best Regards,

Inês

0 Kudos
Message 6 of 6
(1,259 Views)