LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read different files from the same folder

Hello,

 

in the attached .Vi. on the left side you will find 4 paths for the data files.

in the current, I should separate the data files to 4 folders and then run the .vi. 

but if the files are in the same folder. and every data type has a different name.

For example:

path 1 would read the files data1-000, data1-001, data1-002, ..... 

path 2 would read the files data2-000, data2-001, data2-002, ..... 

path 3 would read the files data3-000, data3-001, data3-002, ..... 

path 4 would read the files data4-000, data4-001, data4-002, ..... 

 

How can I make it?, I mean how can I merge the 4 paths  to 1 path

don't care about the .vi contents inside the for a loop. Its already give the expected results. My question outside the for loop. But if you have a suggestion for the code please let me know. 

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

@Khallod wrote:

don't care about the .vi contents inside the for a loop. Its already give the expected results. 


You mean it already gives you pain and sorrow 😉 (the "expected results")?

 

If you have two "Detwctors", make a "Detwctor" sub VI and use that sub VI twice.

 

Subplicate code (a copy) is bad; use sub VIs. If there are slight differences, make a switch and pass it to the sub VI as an option.

 


@Khallod wrote:

in the attached .Vi. on the left side you will find 4 paths for the data files.

in the current, I should separate the data files to 4 folders and then run the .vi. 

but if the files are in the same folder. and every data type has a different name.

 

How can I make it?, I mean how can I merge the 4 paths  to 1 path


Sorry, this just isn't clear enough to understand.

 

You now have 4 files in one folder, and you want to split the 4 files in 4 and save them in 4 different folders?

 

You can probably get all folders from the List Files function, and then in a for loop list the files in those folders. Or use the Recursive File List function, to get all files from a folder hierarchy.

0 Kudos
Message 2 of 6
(2,540 Views)

Thank you for the advice of using the subvi.

 

the question again

this code analyze data of 4 detectors. every detector has around 1000 files.

all the data files are in the same folder. 

every detector data have a different name, for example for the detector 1(data1-000. data1-001 ,,, and so one)

the above code has been designed to read from 4 folders. so I should separate the original data files to 4 folders.

So, how can use the List Files function as you say to make the code read the day files from the same folder and every file name go to its correct place in the vi. !

 

0 Kudos
Message 3 of 6
(2,535 Views)

@Khallod wrote:

this code analyze data of 4 detectors. every detector has around 1000 files.

all the data files are in the same folder.


Clear so far. S o around 4000 files in one folder.

 


@Khallod wrote:

every detector data have a different name, for example for the detector 1(data1-000. data1-001 ,,, and so one)


Detector 2 would be data2-000, data2-001?

 


@Khallod wrote:

the above code has been designed to read from 4 folders. so I should separate the original data files to 4 folders.


It really doesn't show how it does that. There are two paths in, and all files are listed. How does it read from 4 folders? Or is this a "summary" for 2 detectors?

 


@Khallod wrote:

So, how can use the List Files function as you say to make the code read the day files from the same folder and every file name go to its correct place in the vi. !


It's not clear now if you want to:

a) separate the original data files to 4 folders.

b)  use the List Files function to make the code read the day files from the same folder and every file name go to its correct place in the vi.

 

Both seem to be completelly different solutions to the same problem?

 

If you want to use separate the original file to 4 folders, you can use List Folders. Then use a for loop, and for each file extract a folder name (Scan From String would do). Then, optionally (if it isn't there already), make the new folder. Use a move (or copy) to move the file from the original folder to one of the 4 folders.

 

If you read all files from one folder (b), you can use a for loop to split them into 4 arrays. That can be done several ways. You'll have to get the name as a string, and get the detector digits from it (Scan From String would do).

0 Kudos
Message 4 of 6
(2,526 Views)

Hi Khallod,

 


@Khallod wrote:

the question again

So, how can use the List Files function as you say to make the code read the day files from the same folder and every file name go to its correct place in the vi. !


Read the LabVIEW help for the ListFolder function. It has more inputs than just the path, the one named "pattern" might come handy in your case…

Best regards,
GerdW


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

@GerdW wrote:

Hi Khallod,

 


@Khallod wrote:

the question again

So, how can use the List Files function as you say to make the code read the day files from the same folder and every file name go to its correct place in the vi. !


Read the LabVIEW help for the ListFolder function. It has more inputs than just the path, the one named "pattern" might come handy in your case…


e.g. Data001_*.* to get the first detector files.

0 Kudos
Message 6 of 6
(2,520 Views)