DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Importing multiple .csv files into the data portal

Solved!
Go to solution

I am attempting to import multiple .csv files containg data into the data portal. I have a successful code that can clear the data portal of all data, open a dialoge box to find the new data, and open the new data using a .csv dataplugin. I want to enhance this script to be able to have the option to load multiple data sets into the data portal at a time, but I have a limited knowledge of the VBS coding structure. Can someone advise some steps to achieve this solution with minimal VBS coding experience? Thank you all in advance for your help.

0 Kudos
Message 1 of 6
(4,885 Views)
Solution
Accepted by topic author dc13

Hi dc13,

 

The DIAdem command FileDlgShow has the option to load multiple files at once. Please have a look at the DIAdem help for more details and an example.

 

Greetings

Walter

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

Walter,

 

Thank you for the suggestion. I actually went back through my script and found an extra data.root.clear command that alluded me the first time. So I was able to open multiple files, but since it was nested in the for loop, the data kept getting erased. Deleted it, and now can open AND see mulltiple data sets in the data portal. Thanks again.

 

dc13

0 Kudos
Message 3 of 6
(4,853 Views)

Walter,

 

Although my issue is resolved, I have run into a slight annoyance and not sure if there is something that can be done about it. When selecting the multiple files to open with my script, it orders them however it wishes it. Is there a way, either in selecting the files or forcing them to populate in the data portal, to make the files open in the sequence that I chose them?

 

dc13

0 Kudos
Message 4 of 6
(4,842 Views)

Hi DC13,

 

Unfortunately not; the dialog you're using is a Windows dialog which is parameterized for the concerns of DIAdem. The OS returns the chosen files including the order.

 

Greetings

Walter

0 Kudos
Message 5 of 6
(4,835 Views)

Hi dc13,

 

Here's the routine I use to re-order the file paths alphabetically, in case that helps.

 

FilePaths = Split("|" & FileDlgFileName,"|")
Call BubbleSort(FilePaths) ' sort the array of file names 


Sub BubbleSort(NamesToSort)
  Dim i, SwapName, Swapped
  Do ' Until bubble sort of NamesToSort() is finished
    Swapped = False
    FOR i = 1 TO UBound(NamesToSort)-1
      IF StrComp(UCase(NamesToSort(i)), UCase(NamesToSort(i+1))) > 0 THEN
        SwapName  = NamesToSort(i)
        NamesToSort(i)   = NamesToSort(i+1)
        NamesToSort(i+1) = SwapName
        Swapped = True
      END IF ' Name(i) and Name(i+1) need to be swapped
    NEXT ' i
  Loop Until NOT (Swapped)
End Sub ' BubbleSort()

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 6
(4,816 Views)