03-30-2020 06:14 AM
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.
03-30-2020 06:57 AM - edited 03-30-2020 07:14 AM
@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.
03-30-2020 07:12 AM
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. !
03-30-2020 07:26 AM
@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).
03-30-2020 07:28 AM
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…
03-30-2020 07:33 AM
@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.