LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Program to go through all text files in a folder

Solved!
Go to solution

Hi Everyone,

                    I want to write a vi to systematically open text files in a folder, count the cumulative sum of numbers in a particular collumn, write this value to an array and then open the next text file. How can I code this in labview?

 

Many thanks,

Sam

0 Kudos
Message 1 of 8
(5,134 Views)
Solution
Accepted by topic author sw14928

Hi sw,

 

you should use several functions found in the file palette like ListFolder and ReadSpreadsheetFile.

You should use a FOR loop and an ArraySum function.

 

See how far you get…

 

This forum is mainly to discuss specific problems/questions regarding LabVIEW. We usually don't solve other peoples homework for free…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(5,129 Views)

There's also a great VI called "Recursive File List.vi", so you just input the top-level folder and it will dig through the directory for you.

 

temp.png

Message 3 of 8
(5,109 Views)

Thanks, yes I have worked through your algorythm. It currently works once only, is there something wrong with my while loop?

0 Kudos
Message 4 of 8
(5,067 Views)

Thank you for your help

0 Kudos
Message 5 of 8
(5,064 Views)

Hi sw,

 

It currently works once only, is there something wrong with my while loop?

It works as long as you run the VI. And there is nothing wrong with the while loop on its own… 😉

 

But the content of the while loop seems wrong to me!

What's the purpose of the shift register, when the value in the wire NEVER changes?

Why do you read the same file again and again?

What's the point in building an array from the read string?

Did you even try to debug your VI?

Best regards,
GerdW


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

I wanted the shift register to add 1 each loop to add to the filename each time, why does it not do this? I want to build the array so that I can process the data when it is read into labview. I have tried, but my labview is not yet very good I am afraid! Thanks,

Sam

0 Kudos
Message 7 of 8
(5,055 Views)

Hi Sam,

 

I wanted the shift register to add 1 each loop to add to the filename each time, why does it not do this?

Because you didn't program this "+1"…

 

I want to build the array so that I can process the data when it is read into labview.

You need an additional shift register to store the array!

 

I have tried, but my labview is not yet very good I am afraid!

Well, then I suggest to take all those free learning resources offered by NI!

Best regards,
GerdW


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