DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing channel names

Solved!
Go to solution

Hi,

I do have an excel file with channel names. I would like to load certain file to data portal and check if all the names from that excel file are present as a channels in the loaded file. And if there are missing channels, I would like to show message box with the channel names which are not present.

 

Any help appreciated.

Thanks

Jan

0 Kudos
Message 1 of 9
(3,237 Views)

Hi Jan,

 

How should your script know which channel names to expect for each data file loaded?  Is the channel name list always the same for every file?

 

Brad Turpin

Product Support Engineer

National Instruments

0 Kudos
Message 2 of 9
(3,200 Views)

Hi Brad,

 

Thanks for your reply,

Yes the channel name list would be always the same (list in excel). It is just to check if the file loaded includes all the channel names.

It is a pre check before running automated calculation on the file, so it is not time wasted.

 

Many thanks

Jan 

0 Kudos
Message 3 of 9
(3,192 Views)

Hi Jan,

 

It sounds like there are 2 distinct tasks:

1) Load your list of expected channel names from your Excel file

2) Loop through that list of channel names to makes sure they're all present in the Data Portal

 

I'm going to guess that you want help with both of these.  In that case, can you post an Excel file with the list of channel names in it and one of your data files?  I can then send you a VBScript that performs 1) and 2) above.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 4 of 9
(3,184 Views)

Hi Brad,

Thank you for getting back to me so quickly.

I am able to load in an excel file with channel names, but just in case find attach the excel file.

What I struggle more is the script for comparison to the file loaded, and showing an text document wich would say what channels/signal names are missing from the .tdm file. Please also find attached the .tdm file. The .tdm files will be most probably missing most of the channels as the files with mostly all channels in are too big to upload.

Many thanks for help.

0 Kudos
Message 5 of 9
(3,174 Views)

Hi Jan,

 

Please also post the *.TDX file that goes with that *.TDM file.  I can't load the *.TDM file without its partner *.TDX file.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 9
(3,165 Views)

Hi Brad

 

Unfortunately when I tried to attach .tdx I got an error.

I try again with zipped folder.

Jan

 

 

0 Kudos
Message 7 of 9
(3,155 Views)
Solution
Accepted by topic author JanSantora

Hi  Jan,

 

OK, you need to detach and double-click the *.uri file below to register the DataPlugin that reads your Excel file of channel names.  Then you need to adjust the below VBScript to point to the correct DataFilePath and ListFilePath locations on your computer.  Then run this VBScript in the SCRIPT panel of DIAdem.

 

Option Explicit
Dim n, i, iMax, DataFilePath, ListFilePath, ListGroups, ListChannel, FoundChannel, MissChannels
DataFilePath = CurrentScriptPath & "2HJVP218_CAN_FR_CCP_Data 2017-08-01 07-37-00-536847 Partition 0.TDM"
ListFilePath = CurrentScriptPath & "D4H.xlsx"
Call Data.Root.Clear
Call DataFileLoad(DataFilePath, "TDM")
Set ListGroups = DataFileLoad(ListFilePath, "JanSantoraList_XLSX")
Set ListChannel = ListGroups(1).Channels(1)
n = -1
iMax = ListChannel.Size
ReDim MissChannels(iMax)
LogFileWrite "Found Channels"
LogFileWrite "-----------------"
FOR i = 1 TO iMax
  FoundChannel = ""
  On Error Resume Next
  Set FoundChannel = Data.GetChannel("*/" & ListChannel(i))
  On Error Goto 0
  IF NOT IsObject(FoundChannel) THEN
    n = n + 1
    MissChannels(n) = ListChannel(i)
  ELSE
    LogFileWrite ListChannel(i)
  END IF
NEXT ' i
ReDim Preserve MissChannels(n)
MsgBox "Missing " & n+1 & " Channels" & vbCRLF & String(25, "-") & vbCRLF & Join(MissChannels, vbCRLF)

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 8 of 9
(3,146 Views)

Hi Brad,

 

 

Thank you very much for your help. It works perfectly.

 

Jan

 

 

0 Kudos
Message 9 of 9
(3,126 Views)