DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Combining Text with Numerical Value

Solved!
Go to solution

I am trying to process some data in DIAdem and export it as a CSV with two columns. I have done this with my numerical data; however, I was looking to add some test information in the rows above this data (See below for example output). Is there any way to do this in DIAdem?

 

Column 1               Column 2

Test Number          001

Test Time               15:30:00

Sensor Location     Hindfoot_Right

Time (sec)              Value

-0.5                         123.4

-0.4                         167.8

-0.3                         234.6

0 Kudos
Message 1 of 2
(1,480 Views)
Solution
Accepted by topic author sfol

Hi sfol,

 

for similar purpose we use following code.

The pre-requirement is, that all information you export is stored in channel properties in your data set. For example, the property "MPX" in our case.

However, this can be done before CSV export.

 

For sensor location in your example this could be done.

Test number and test time can be extracted from the properties of the Data.Group and placed in the header.

 

Dim FileNamePath, HeaderLines, Group
'Call DataDelAll
'Call DataFileLoad(AutoActPath & "Example.tdm")
FileNamePath = "C:\Data\" & Data.Root.Name & ".CSV"
HeaderLines = "Version 1.10" & vbCRLF & RTT(TTR(CurrDateTime), "#yyyy-mm-dd hh:nn:ss.ffff")
'Set Group = Data.Root.ActiveChannelGroup
Set Group = Data.Root.ChannelGroups(1)
Call GroupAsciiExport(Group.Channels, FileNamePath, HeaderLines)
'Call ExtProgram(FileNamePath)


Sub GroupAsciiExport(Channels, FileNamePath, HeaderLines)
  Dim j, Ch1, ChN, HdrStr, SelChans, ExportGroup, SourceGroup, SourceChan, SourceName
  j = Channels.Count
  HdrStr = GetHdrStr(Channels)
  Ch1 = Channels(1).Name
  ChN = Channels(j).Name
  Channels(1).Name = HeaderLines & vbCRLF & Ch1 
  Channels(j).Name = ChN & vbCRLF & HdrStr
  Call DataFileSaveSel(FileNamePath, "CSV", Group.Channels)
  Channels(1).Name = Ch1
  Channels(j).Name = ChN
End Sub ' GroupAsciiExport()


Function GetHdrStr(Channels)
  Dim j, Channel, HdrStr, prop
  ' Creates a row with channel units
  FOR Each Channel In Channels
    HdrStr = HdrStr & ChnDim(Channel)  & vbTAB
  NEXT ' Channel
  HdrStr = Left(HdrStr, Len(HdrStr)-1) & vbCRLF
  ' Creates next row with channel description
  FOR Each Channel In Channels
    HdrStr = HdrStr & ChnComment(Channel) & vbTAB
  NEXT ' j
  HdrStr = Left(HdrStr, Len(HdrStr)-1) & vbCRLF
  ' Creates next row with MPX number (from property "MPX")
  FOR Each Channel In Channels
    If Channel.Properties.Exists("MPX") then
      prop = "MPX_" & Channel.Properties("MPX").Value
    Else
      prop = ""
    End If
    HdrStr = HdrStr & prop & vbTAB
  NEXT ' j
GetHdrStr = HdrStr
End Function ' GetHdrStr()

  

Maybe not the best solution, but for us it works (DIAdem 2015 and 2019).

Hope this helps.

Message 2 of 2
(1,431 Views)