08-12-2014 12:11 PM
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.
Solved! Go to Solution.
08-13-2014 01:58 AM
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
08-13-2014 08:58 AM
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
08-13-2014 02:44 PM
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
08-14-2014 12:32 AM
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
08-14-2014 12:04 PM
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