DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Import all files in zip

Hi,

 

I have a compressed ZIP file that has multiple TDMS files that I need to append when loading.

I'm trying to do this via a custom Data Plugin.

I tried out the example code:

Sub ReadStore(FileName)
Dim TempFolder
TempFolder = AutoRemove.CreateFolder()

Dim FileList
FileList = Unzip(FileName, TempFolder)
Call Root.ImportStore(TempFolder & FileList(0), "TDMS")
End Sub

This works for a single file.

I modified it for multiple files but cannot get it to work.

 

Sub ReadStore(FileName)
Dim TempFolder
TempFolder = AutoRemove.CreateFolder()

Dim FileList, ListLength, i, file
FileList = Unzip(FileName, TempFolder)
ListLength = Ubound(FileList) - LBound(FileList)+1
for each file in FileList
Call Root.ImportStore(TempFolder & file, "TDMS")
next
End Sub

Also I found another method called OpenFile() but no luck with this either.

 

Any help or pointer would be much appreciated.

 

Cheers,

Deepak

 

0 Kudos
Message 1 of 4
(1,405 Views)

Had some luck when it came to combing the TDMS files thanks to help on this forum, where I used the shell command.

 

oShell.run "cmd /K copy /b " & FileList(0) & " + " & FileList(1) & " " & file, 0 , false

 

Now the issue is with Diadem 2020 not being able to generate the combined TDMS file when using 

 

Navigator.LoadData(DataLink,oMyImportParameter)

 

while it loads fine when I ran it locally using,

 

Call DataFileLoad(FileName,"TDMS")

 

The error that pops up is -

The value is invalid for the "ImportObject (as ABS) " argument of the "LoadData" method.

 

Any help?

 

Cheers,

Deepak

0 Kudos
Message 2 of 4
(1,359 Views)

Hi Deepak,

 

The VBScript DataPlugin API does have tools to unzip a ZIP file into a Temp directory (and delete the unzipped contents afterward).  And it also has provisions for concatenating multiple DirectAccessChannels into 1 Channel in the Data Portal.  But I'm not convinced that housing all this in the DataPlugin makes the most sense.  I think it's better to have a separate process that unzips each ZIP file and concatenates the TDMS files with the DOS Shell command like you have.  After that you can load the concatenated TDMS file normally in DIAdem with the standard TDMS DataPlugin.  This should work straightaway.  Does your concatenated TDMS file load when you drag it into the Data Portal in DIAdem?  Are you able to connect to it with a TDMS VI in LabVIEW?

 

I noticed the variable "DataLink" in your code.  Are you wanting to perform some of this in an Analysis Server task?

 

Brad Turpin

Principal Technical Support Engineer

National Instruments

Message 3 of 4
(1,286 Views)

Hi Brad,

 

Thanks for your inputs. As you had suggested, I did eventually end up building a small utility in Python that unzips and combines the TDMS files using dos shell commands.

 

Yes. Your observation of trying to load these files in an Analysis script is right.

 

I am trying to load a bunch of files in a folder using the "Append" option and run an analysis script on the server. The one concern I have is suppose someone dumps multiple folders into my raw data location on server, the analysis script will end up appending all of the files since it sees them as a flat list instead of them in their respective folder/sub-folders.

 

I'm currently scripting out a solution to try and achieve this.

My second option is to ask engineers to dump zip files instead of complete folders and then using the zip reader in a DataPlugin, read the files from the temp location where the data plugin should store these files temporarily and append them.

 

Let me know if you have any thoughts on this.

 

Thanks,

Deepak

0 Kudos
Message 4 of 4
(1,088 Views)