DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

diadem,folder

Hi,

 

I m having a dialog box which is showing a number of folders in that, i want user to select any of the folder & that folder( all tha files) should be loaded in dataportal .is there any function available for that?

 

Thanks

Nidhi 

0 Kudos
Message 1 of 5
(4,595 Views)

Hi Nidhi,

 

The short answer is "Yes".  Are you expecting the files in the folder to all be the same type of file, say "*.TDM", or might they have different file types (*.DAT, *.CSV, etc.)?  The long answer is that there are several ways of returning a list of file paths inside a particular folder, and with each method you have the choice whether to filter that list of files to exclude unwanted file types (*.DOC, *.PDF, etc.).  You would then loop through the file list and load each one with DataFileLoad().  Do you want them all in the Data Portal at the same time, or do you want to process each one separately, one after the other?

 

Brad Turpin

DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 2 of 5
(4,577 Views)
Hello Brad,

that is exactly my problem!
I want to load all tdms files for each folder separately, do some calculations and save this. Then load the files from the next before defined folder and so on.
What could be a solution for this?

Best regards,
Headni
0 Kudos
Message 3 of 5
(3,904 Views)

Hi Nidhi,

 

I recommend you look into the DirListGet() function.  You can use it to return an array of all the subfolders in a main folder, or of all the files of a particular type in the main folder, like this:

 

StartFolder = ProgramDrv & "Examples\Data"
FilePaths = DirListGet(StartFolder, "*.TDMS", "filename", "FullFilenames")
iMax = UBound(FilePaths)
FOR i = 0 TO iMax
  Call Data.Root.Clear
  Call DataFileLoad(FilePaths(i), "TDMS")
  ' Do your analysis here
  ' Export your results here
NEXT

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 5
(3,880 Views)

Hello Brad,

 

thanks, your input helped a lot!

Here is my solution for it:

1. Define a array of all folders in a directory

2. Define a array of files which I want to handle in each folder

3. Do similar calculations with the defined files in each folder

 

Dim vFoundFiles, iCount, i, Dateien, meinVerzeichnis, ReturnValue, Pfad

meinVerzeichnis = "D:\temp"   'Startpfad festlegen
ReturnValue = PathDlgShow("Verzeichnisauswahl...", meinVerzeichnis)
Pfad = outputpath
              
call FileNameGet("Any","FileRead", Pfad, "TDM data (*.tdm),*.tdm", "files.txt", False, "Data selection") 'Liste aller ausgewählter Dateien wird angelegt (und in txt file geschrieben)
Dateien = Split(FileDlgFileName,"|")  'Split der mit "|" getrennten Dateinamen in Array

vFoundFiles = DirListGet(Pfad, "*.*", "filename", "DirectorynamesRecursive")  'Array aller Ordnernamen im vorher definierten Verzeichnis wird angelegt
If IsArray(vFoundFiles) Then
          For iCount = Lbound(vFoundFiles) to Ubound(vFoundFiles)           
                  call data.Root.Clear                              
                        For i = 0 To Ubound(Dateien) 'Laden aller ausgewählter Datein (je Ordner) ins Datenportal
                            call datafileload(vFoundFiles(iCount) &"\"& Dateien(i), "tdm")                        
                        next
'------------------------------------------------------------------------------------------------------------
                  'Berechnungen
                  call datafilesave(vFoundFiles(iCount) & "\" & "ergebnis", "tdm")
'------------------------------------------------------------------------------------------------------------                  
          Next
End If

regards,

headni

0 Kudos
Message 5 of 5
(3,805 Views)