DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Read tdms file metadata before opening the file

Solved!
Go to solution

Hello,

I have a bunch of tdms files and i want to use the data reduction method when i open them to get the min/max/mean for each channel for every second.  The channels have different sample rates, and the number and location of channels are not consistent from the first file to the last.  Is there a way i can read the metadata first to get the channel name and "wf_increment", then use the DataFileLoadRed command to load each channel based on the sample rate?  

 

I thought of using the DataFileLoadSel command to open the first 100 samples of each channel in the file, then use information from that instance to do the DataFileLoadRed.  Is there anything more direct than this method?

 

Thanks

 

Chris

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

Hello Chris,

 

did you already try to register the data instead of loading?

Call DataFileLoad(MyFolders(0)&"DATA.tdms","TDMS","Register")

 

I guess this could be sufficient for you. In first step you just collect the information about the file content, but don't change the data. And then (2. step) you really load only the channels you need...

 

Could it work for you?

0 Kudos
Message 2 of 4
(2,459 Views)
Solution
Accepted by topic author Chris@GE

There is an API that allows you to access file meta without loading the file. Check the DIAdem help for

CreateDataFileHeaderAccess

maybe this will help

Option Explicit

dim filePath : filePath = DataReadPath & "Example.tdms"

Dim dataFileHeaderAccess : set dataFileHeaderAccess = CreateDataFileHeaderAccess 
dim dataStore : Set dataStore = dataFileHeaderAccess.Open(filePath ,"TDMS", True)

dim channelO : set channelO = dataStore.RootElements(1).Children("Noise data").Children("Noise_1")

dim channelP : set channelP = channelO.properties
' make sure we can access custom properties
channelP.ListInstanceProperties = true

if channelP.Exists("wf_increment") then
  MsgBox channelP("wf_increment").value
end if

 

 

Message 3 of 4
(2,456 Views)

Thank you Andreas... that is what i wanted! 

0 Kudos
Message 4 of 4
(2,440 Views)