12-15-2020 08:42 PM
I attached an example file.
What I'm curious about is this.
1. Merge channels from different groups within the data portal.
2. Compare and list the channels in the two files.
3. File 1 has a "T_Cell ['C]" channel, but file 2 does not.
4.Sort and Merge by Date.
5.Fill in empty data in "T_Cell ['C]" with zero when performing a Merge.
how can i do?
12-19-2020 02:08 PM
Hello KyutaeTenergy,
Here is a little script that does most of what I think you want.
It will make a new summary group, that contains all the unique data channels.
Need to understand better how the merge function will need to be done and what specifically orders the data channels between the two files before the merge part of this can be made.
Paul
ps. change the path to files for loading.
'-------------------------------------------------------------------------------
'-- VBS script file
'-- Created on 12/19/2020 14:07:43
'-- Author: --- Paul Smith
'-- Comment: ---
'-------------------------------------------------------------------------------
Option Explicit 'Forces the explicit declaration of all the variables in a script.
data.Root.Clear
Call DataFileLoad("C:\Users\pesmi\Downloads\1.csv", "", "Load|ChnXYRelation")
Call DataFileLoad("C:\Users\pesmi\Downloads\2.csv", "", "Load|ChnXYRelation")
dim ChnsFirstGroup,chnsSecGroup
dim oChan,oChans
dim oGrp_1,oGrp_2
set oGrp_1 = data.Root.ChannelGroups("[1]")
set oGrp_2 = data.Root.ChannelGroups("[2]")
if oGrp_1.Channels.Exists("NoName") then
oGrp_1.Channels.Remove("NoName")
end if
if oGrp_2.Channels.Exists("NoName") then
oGrp_2.Channels.Remove("NoName")
end if
dim oGrp_sum: set oGrp_sum = data.Root.ChannelGroups.Add("All_chans")
set ChnsFirstGroup = oGrp_1.Channels
oGrp_sum.Activate
logfilewrite oGrp_1.Channels.Count
dim odict_1 : set odict_1 = createobject("scripting.dictionary")
for each oChan in ChnsFirstGroup
if not odict_1.Exists(oChan.name) then
call odict_1.Add(oChan.Name,"")
Call ChnCopy(oChan,oGrp_Sum.Name&"/"&oChan.name,True)
logfilewrite "Group 1 "&oChan.Name & "copied to summary group"
end if
next
logfilewrite "dictionary 1 size: " & oDict_1.Count
set chnsSecGroup = oGrp_2.Channels()
logfilewrite oGrp_2.Channels.Count
logfilewrite "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
logfilewrite "Channels in 2nd group that are not in 1st group"
for each oChan in chnsSecGroup
if not odict_1.Exists(oChan.Name) then
Call ChnCopy(oChan,oGrp_Sum.Name&"/"&oChan.name,True)
logfilewrite oGrp_Sum.Name&"/"&oChan.name
end if
next
' Now will need to handle the merging of the rows of what was added from 2nd group so that lines up with the 1st group.
' in this regard, will need to understand the log data and time column better.
' will the values in 2nd group. need to be appended or will the values be interspersed in 1st groups data?