LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if file has right extension(file type), if true, pass it along

Hi,

 

I am extremely new at LabVIEW programming and wish to implement a basic read file from text file.

 

So far I have this set up:

basic.PNG

I got the compound arithmetic function to output true for both conditions, but I am confused as to how with that boolean condition to make the program pass along the file.

 

In addition, is there a function to read incoming text files with numerous columns and fix the spacing between columns to be read into an array and utilized? 

0 Kudos
Message 1 of 7
(5,456 Views)

I don't understand what you mean by "as to how with that boolean condition to make the program pass along the file.".

 

I don't understand what you mean by " fix the spacing between columns to be read into an array and utilized", but if you want to read a text file with data formatted into columns, use Read from Spreadsheet File.

0 Kudos
Message 2 of 7
(5,447 Views)

Sorry I wasn't clear with my first post.

What I meant by "as to how with that boolean condition to make the program pass along the file" is when a user selects a file from the browser button, my program will check if it's an existing file and also if it has the right extension (which is a .txt file), if both conditions hold true, then the program will continue with that file and pass it along to be used for other functions. 

 

"fix the spacing between columns to be read into an array and then utilized" is meant by fixing the spacing between columns of data in a txt file. Some of the columns have 2 spacing between and others have 4 spacing between them. I wish to make them one spacing apart, in other words, to manipulate the incoming text file so it's easier to be read by the program into an array.

0 Kudos
Message 3 of 7
(5,443 Views)

@TeddyLu wrote:

 

I got the compound arithmetic function to output true for both conditions, but I am confused as to how with that Boolean condition to make the program pass along the file. 

basic.PNG


Does the program in need of, checks for extension file to be .txt file (in this case) and passes only files with such extensions..?! Am I clear..

If so, you can achieve the same with above code..

 

 

0 Kudos
Message 4 of 7
(5,420 Views)

Hi Teddy,

 

when a user selects a file from the browser button, my program will check if it's an existing file and also if it has the right extension (which is a .txt file),

Using the FileDialog ExpressVI you can configure it to select only existing files and you can provide a file pattern (like "*.txt") to only show files with correct suffix…

(It's not fool proof, but will help a lot!)

 

if both conditions hold true, then the program will continue with that file and pass it along to be used for other functions. 

So you want to implement something like

IF statement THEN do something

IF-THEN-ELSE usually is done in LabVIEW using a case structure…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 7
(5,396 Views)

use a case structure and pass the path if the extension is matching and use scan from string function might help you in the spacing problem

bp
0 Kudos
Message 6 of 7
(5,371 Views)

pathSelection.png

In case of state machine based on the Boolean case can be selected.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 7 of 7
(5,345 Views)