DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

.txt-DataPlugin - Data arrangement

Solved!
Go to solution

Hi,

 

I'm trying to create a DataPlugin for reading .txt-files. The values of each desired channel are arranged in rows (lines in the txt-file). The collums are separaded by tabulators.

 

I can't figure out how to set the data arrangement in DIAdem 2015s DataPlugin-Wizard.

 

 

 

Here's a Quick example:

 

 

####EXAMPLE.TXT#################################################

 

#Header - ignore this line

value0_1    value0_2    value0_3    value0_4

value1_1    value1_2    value1_3    value1_4

 

####EXAMPLE.TXT#################################################

 

 

I want all value0_x to be in channel 0.

All value1_x should be in channel 1.

 

I hope understand what I am looking for.

Thank you in advance!

0 Kudos
Message 1 of 4
(4,071 Views)
Solution
Accepted by nilsf

I am not sure if it can be configured in the wizard but it can be written by a few lines.

Store this code into an new created DataPlugin. (Settings->Extensions->Dataplugins)

 

Option Explicit

Sub ReadStore(File)
  File.Formatter.Delimiters = vbtab
  File.Formatter.LineFeeds = vbcrlf
  file.Formatter.CommentSign = "#"
 
  dim groupObj : set groupObj = root.ChannelGroups.Add("group")
  do
    dim chObj : set chObj = groupObj.Channels.Add("channel_" & groupObj.Channels.Count, eR64)
    dim nextVal : nextVal = File.GetNextStringValue(eR64)
    dim i : i = 1
    while not isempty(nextVal)
      chObj(i) = nextVal
      nextVal = File.GetNextStringValue(eR64)
      i = i + 1
    wend
  Loop Until not File.SkipLine
End Sub

Should read files of the form

#Header - ignore this line
0.1	0.2	0.3	0.4
1.1	1.2	1.3	1.4
2.1	2.2	2.3	2.4
Message 2 of 4
(4,057 Views)

I was wondering because the ASCII Import Wizard (not included in my version of DIAdem for some reason) gives the option to choose the data arrangement. http://zone.ni.com/reference/en-XX/help/370859J-01/gfsascii/ascii/hidd_step1/

 

Anyway, your script worked perfectly for me. Thank you so much!

0 Kudos
Message 3 of 4
(4,040 Views)

The ASCII and Excel DataPlugin Wizards are available in the Advanced and Professional versions of DIAdem, the Base version does not support the Wizard features.

 

We are glad that Andreas' Script was helpful for your data set ...

 

     Otmar

Otmar D. Foehner
0 Kudos
Message 4 of 4
(4,021 Views)