09-23-2019 03:40 PM
I am wanting to load all groups, channels, and their properties from a .txt file. It seems when I save my .tdms file as a .txt it only saves the channel names. Is there a way to save/export all the associated info of the group -> channels->properties to a .txt or other ASCII format to be edited and then load/import back into DIAdem?
I have created DataPlugins to pull in group, channel, and data from an ASCII format, but cannot figure out how to pull in properties of the group/channel.
I basically want a repository containing all information of the DIAdem file to where I can load it into the data portal without having to add properties afterwards.
09-24-2019 09:02 AM
It would be nice to have a plugin to pull properties from a text file... I never got to figuring that out but I am using some scripts to do that. I can show you how if you can post a small file with fake properties that is structured similarly to the files you are working on.
09-24-2019 09:48 AM
Thank you for the response. The properties are structured such that LabVIEW will cycle through each Group and Channel pulling out the properties to populate the associated sequence in TestStand. We use the LabVIEW structure to populate arrays containing specifics for the tests quickly. We have multiple DIAdem files of which the later ones will contain actual values rather than just the TestStand sequence like the ones I attached.
09-24-2019 10:42 AM - edited 09-24-2019 10:43 AM
OK so I am still not sure what exactly you need. I use a script that reads lines off a txt file which I will post below. I also use a script for reading/writing values to and from Excel spreadsheets. Let me know if this is getting closer to what you're looking for
'------------------------------------------------------------------------------- '-- VBS script file '-- Created on 09/26/2017 15:00:56 '-- Author: Gleb Sklyr '-- Comment: Function to return specified lines with a separator off a text file '------------------------------------------------------------------------------- Option Explicit 'Forces the explicit declaration of all the variables in a script. DIM SUB_NAME, FSO Set FSO = CreateObject("Scripting.FileSystemObject") ' READ LINES OFF A TEXT FILE ' ARG 1: Path of the text file ' ARG 2: Start line to read ' ARG 3: End line to read ' ARG 4: The regular expression to separate each line ' RETURN: String with specified lines separated by VBCRLF ' NOTES: If lineEnd = -1 then will read till the end of file Function readLines(txtPath, lineStart, lineEnd, regx) SUB_NAME = "readLines" & ": " Call LogFileWrite(SUB_NAME & "Started exeution") ' START If FSO.FileExists(txtPath) Then ' Check path exists If TypeName(lineStart) = "Integer" Or TypeName(lineStart) = "Double" And TypeName(lineEnd) = "Integer" Or TypeName(lineEnd) = "Double" Then ' Check valid ARGS If lineStart > 0 And lineEnd >= -1 And Not lineEnd = 0 And ((lineStart <= lineEnd) Or (lineStart > 0 And lineEnd = -1))Then ' check logical line start/end Dim txtFile, outputStr, lineCount, i Set txtFile = FSO.OpenTextFile(txtPath) outputStr = "" lineCount = lineStart For i = 1 To lineStart - 1 Step 1 ' Skip lines till start line is reached txtFile.SkipLine() Next If lineEnd = -1 Then ' If -1 then read till the end of file Do Until txtFile.AtEndOfStream ' Loop every line till the last line outputStr = outputStr & txtFile.ReadLine() & regx Loop Else Do Until lineCount = lineEnd + 1 ' Loop every line till the requested line outputStr = outputStr & txtFile.ReadLine() & regx lineCount = lineCount + 1 Loop End If readLines = outputStr Else Call LogFileWrite(SUB_NAME & "Line start and line end arguments are not logical... Aborting") End If Else Call LogFileWrite(SUB_NAME & "Line start and line end arguments must be integers or doubles... Aborting") End If Else Call LogFileWrite(SUB_NAME & "Provided text file path is invalid... Aborting") End If ' END Call LogFileWrite(SUB_NAME & "Ended exeution") End Function ' EXAMPLE USE Dim FileStr, FileArr, i FileStr = readLines("C:\Users\111660\Desktop\ex.txt", 1, -1, VBCRLF) FileArr = Split(FileStr, VBCRLF) For i = 0 To UBound(FileArr, 1) Step 1 Call LogFileWrite(FileArr(i)) Next
Attached is an example file and the code in the very button is an example of how to use the readlines function. You will have to change the path of the file to match yours. I log the values into the logfile in the example but you can take them and break them down by ":" and assign property-value pairs to channels/groups
09-24-2019 12:19 PM
Lets try this.. Do you know a way to export the .tdms file from DIAdem into a .txt or .csv wherein the properties are included?
09-24-2019 12:41 PM
No... I would suggest either keeping a data file and a properties file or add the properties to the top of the file after saving the data. You'd have to come up with a good format to save File/Group/Channel properties so that it would be easy for you to process/interpret. Ideally, just save the data as TDMS and have scripts to process the data into TDR template (PDF reports). That way data is always available and searchable by properties and you can use the script anytime to generate a user readable report report.