LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read all the files in a folder and more... HELP

Hi guys, I am new with LabVIEW and i need some help to get starded.

I have a folder with a lot of .txt files. 

1) First of all i have to find a way to open all them sequentially.

2) For each file i have to extract the name of the file opened and the value of the streses detected (SF PR [T]) and then i have to do a moving average with 2 elements and find the maximum and minumum value.

3) repeat the step #2 for each .txt file.

4) create an excel file/ csv file with the name of the file, the maximum value and the minumum value

 

ATTACHED YOU CAN FIND AN EXAMPLE OF THE .TXT FILE 

thanks a lot

0 Kudos
Message 1 of 10
(3,658 Views)

Use List Folder function to get all the txt files from the folder then use a For Loop to open each file and get the data out. Your txt file seems to be of spreadsheet type with ";" delimiter so you can read them using Read Delimited Spreadsheet.vi. Find a way to get the SF PR [T] data out of the whole 2D array. If stuck, ask again for help but attach the VI so we can see what have you tried so far.

Lucian
CLA
0 Kudos
Message 2 of 10
(3,629 Views)

Hi Gquadro,

 

LucianM already pointed out how to get a list of files and pass their paths to a For loop: use List Folder together with a pattern (*.txt) and then an autoindexing tunnel.

That solves your point #1.

For #2, you can use Strip Path to take just the filename. If you want it without the extension, take a look at the Get File Extension VI which outputs (from a path) the filename without extension as one of the outputs. You could optionally open this VI to see how it works, and copy only the parts you really need if you prefer.

The For loop covers #3.

For #4, you can use an autoindexing output of either a Cluster or an array of strings - if you convert your values to strings within the loop it will be easy to use Write Delimited Spreadsheet to create a CSV file from the 2D array of strings (build a 1D array inside the loop of name, max and min, then the output of the For loop will be a 2D array for WDS).

 

You can do #2's b) part (SF PR [T]) by either matching the column names and looking for one with the key you want, or if they are always the same order and number of columns, simply using Index Array. Using a matching algorithm will make it a bit more self-explanatory, but will cost some tiny amount of time.


GCentral
0 Kudos
Message 3 of 10
(3,617 Views)

Hi! 

Thanks a lot for your help.
I attach what i have done; now i have to extract "SF PR [T]", could you help me?

0 Kudos
Message 4 of 10
(3,615 Views)

Here's a example to get you started:

Test (1).png

 

I used h*.txt as a pattern, to avoid other files, but you should just use *.txt if that's what you need.


GCentral
0 Kudos
Message 5 of 10
(3,613 Views)

could you share with me your code?

0 Kudos
Message 6 of 10
(3,601 Views)

That was a snippet, you should be able to drag it into LabVIEW, at least LV2019.

 

What version of LabVIEW are you using?


GCentral
0 Kudos
Message 7 of 10
(3,596 Views)

LabVIEW Robotics 2019

it is a png, and if i drag it into Labview it appears a link

0 Kudos
Message 8 of 10
(3,590 Views)

Snippets are a bit.... finicky. You have to open the preview window and use the download button (which has no icon). Then the saved png can be dragged into LabVIEW to generate code.

 

Annotation 2020-02-02 094441.png

 

Use the indicated button from the original post.

Message 9 of 10
(3,583 Views)

If you have it downloaded, it should be possible to drag from Windows Explorer to the block diagram and place the code. If you don't do it correctly (it can be fairly fiddly - I'm not sure what the best tips are) then you might get a picture instead. But it is possible to drop the code.

 

In any case, the VI is attached to this post, which may or may not be easier.


GCentral
0 Kudos
Message 10 of 10
(3,575 Views)