DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

comma and tab delimited files

I receive text files from Germany that contain data in the format
 
Number,<tab>Number,<tab>Number,<tab>Number
 
As an added bonus the "Number"s are comma delimited instead of period deliminated as we use in the US
For Example a line from the text file reads:
0,000,<tab>5,345,<tab>-7,234,<tab>7,132
 
Is there a way to use ,<tab> as my delimiter to import the data into DIADEM?
 
I have tried checking "Other" under Delimiter Characters and inputting #044#009, but this just selects the Comma and Tubulator buttons and I end up with:
0  000  5  345  -7  234  7  132
 
However i need:
0.000  5.345  -7.234  7.132
 
There are about 43000 lines of data in each file and about 50 files.
 
Any suggestions on how to use the data that we have been sent would be appreciated.
 
Thank you,
 
Travis Briggs
0 Kudos
Message 1 of 7
(4,154 Views)

Hi Travis

Do I understand correctly that you trying to import this data with the ASCII Import Wizard?  If so, then there is an opportunity to pick "dot" or "comma" for your numeric data in the third step.

Greets,

Myrle

P.S.  If you were to write a DataPlugin for this format then you could provide "." or "," as a File.Formatter.DecimalPoint.

******************
For tips and tricks on creating VBScript DataPlugins go to http://dataplugins.blogspot.com.
0 Kudos
Message 2 of 7
(4,125 Views)
Myrle,
 
You are correct that I am trying to import the data with the ASCII Import Wizard.  My problem seems to be that the data contains commas as period deliminators and commas as data value deliminator.  (I.e. 1,234, 5,678 should import as 1.234 and 5.678).  The comma seperating the two data values is followed by a <tab>, so I was hoping that there was a way to make my deliminator equal to <comma><tab> together.
 
To make a two character deliminator do I need to write a DataPlugin?
 
Thank you for your help.
 
Travis Briggs
0 Kudos
Message 3 of 7
(4,130 Views)

Hello Travis,

I don't see a way to do exactly this with the ASCII Import Wizard but it should be fairly easy with a DataPlugin. You can check out the DataPlugin help at www.ni.com/dataplugins. The trick to this format is going to be to set the comma as a trim character. I was able to read this data:

alsdkjfasldkjg
123,567, 3458,876
890,123, 9723,876

Using this plugin:

Option Explicit

Sub ReadStore (File)
  'Tell the file how the string data is formed.
  File.Formatter.Delimiters = vbTab
  File.Formatter.LineFeeds = vbCrLf
  File.Formatter.DecimalPoint = ","
  File.Formatter.TrimCharacters = ","

  'Move to the start of the data
  Call File.SkipLine()

  'Create a file accessor
  Dim Block : Set Block = File.GetStringBlock()
  Dim i
  While Not IsEmpty(File.GetNextStringValue(eR64))
    Call Block.Channels.Add ("FileData", eR64)
  Wend

  'Provide the data to USI
  Dim ChannelGroup : Set ChannelGroup = Root.ChannelGroups.Add ("MyChannelGroup")
  Dim DirectAccessChannel
  For Each DirectAccessChannel In Block.Channels
    Call ChannelGroup.Channels.AddDirectAccessChannel (DirectAccessChannel)
  Next
End Sub

I've attached the DataPlugin as a uri file too, to make it easier for you to install it and then adjust it for your specific needs.

Hope that helps,

Myrle

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

Hi Travis,

 

I recommend to you to forget about the comma as a delimiter character, use only the <tab>, then DIAdem will select your data with a comma at the end like “4,567,” but don’t worry about this, continue the ASCII Import Wizard process. On the next step be sure that you choose comma for the numeric channel format, then finish the process and DIAdem should import your data correctly, ignoring the comma at the end of your data, at least that works for me using DIAdem 9.1

 

Good luck,

Marc.

0 Kudos
Message 5 of 7
(4,095 Views)

Myrle,

Thank you for the Plugin. 

It imported all but the first row of data perfectly.  I took a look at the code closer and commented out the "Call File.SkipLine()" and it works great now.  The code is also a good start for me to learn about DataPlugins.

Thank you again.

Travis Briggs


0 Kudos
Message 6 of 7
(4,084 Views)

Marc,

Thank you for your information on importing the data from Germany.  This also worked well in DiaDem 10.  I will give my colleague both your method and Myrle's.  He will be very happy that he can load his data into DIADem to analysis it.

Thank you.

Travis Briggs

0 Kudos
Message 7 of 7
(4,083 Views)