DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

dataplugin for tab, comma, space delimiters

I have an ASCII file that contains data formatted as:
 
<number> tab tab <number> tab tab <number>  tab tab <number> comma space <number> comma space <number> on each line.
 
The data has been successfully imported using a STP file. However, that assumes a static format. The file header will have different numbers of lines and the number of data points will change. The header can be changed easily but the data portion is harder to modify.
 
There are Diadem variables such as ASCIISeparator(i), i = 1, ASCIINumber but these are not available to a plug in.
 
Will I need to make a dummy string channel first, create 6 real channels, parse each string and then use the Values(i) property to fill them followed by deleting the dummy string channel?
 
Doable but would like to know if there's a better way.
 
Thanks,
 
Steve Gottschalk
0 Kudos
Message 1 of 3
(3,263 Views)

Hi Steve,

I'm not sure based on your description whether the delimiters are always as you describe them or whether you mean that they can be a random combination of delimiters.  If they can be a random combination of delimiters then you'll probably have to parse each string, but the DataPlugin API can help you.  Use GetNextStringValue(eR64) and then check with IsNull in this case.  (If this is the case let me know and I'll try to provide a more complete description.)

If they are exactly as you describe them, then the solution is easier; you can use the direct access channels.  First set up formatting information like this:

  File.Formatter.Delimiters = vbTab & "," 'Tab and comma are both delimiters.
  File.Formatter.TrimCharacters = " " 'Since that space is never alone just trim it.

Then create channels in the block for all of the positions between the delimiters, but you don't add the space-holder channels to the group.  In the example you described above this would look roughly like this:

  Dim Block : Set Block = File.GetStringBlock()
  Dim DirectAccessChannel : Set DirectAccessChannel = Block.Channels.Add("FileData1", eR64)
  ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)
  Set DirectAccessChannel = Block.Channels.Add("FileData2", eR64)
  'ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)
  Set DirectAccessChannel = Block.Channels.Add("FileData3", eR64)
  ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)
  Set DirectAccessChannel = Block.Channels.Add("FileData4", eR64)
  'ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)
  Set DirectAccessChannel = Block.Channels.Add("FileData5", eR64)
  ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)
  Set DirectAccessChannel = Block.Channels.Add("FileData6", eR64)
  'ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)
  Set DirectAccessChannel = Block.Channels.Add("FileData7", eR64)
  ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)
  Set DirectAccessChannel = Block.Channels.Add("FileData8", eR64)
  ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)
  Set DirectAccessChannel = Block.Channels.Add("FileData9", eR64)
  ChannelGroup.Channels.AddDirectAccessChannel(DirectAccessChannel)

 

Hope that helps,

Myrle

******************
For tips and tricks on creating VBScript DataPlugins go to http://dataplugins.blogspot.com.
0 Kudos
Message 2 of 3
(3,235 Views)

Hello Myrle,

Thank you for the solution. It works! Rather unusual way of handling the double tabs by creating a direct access channel for the tab data but not adding it to the data portal.I'll have to remember that.

Steve

0 Kudos
Message 3 of 3
(3,179 Views)