DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Coverting String channel to Data Channel

Solved!
Go to solution

I have an issue that I have tried to accomplish through a .URI file but can seem to make it work right for me.  I have a channel that the original data is in TEXT format and the data in the channel is Phone number in the following format 6667779999 or 4343. Can anyone help me with a script suggestion to convert this. Most of my ATTEMPTS end up with a 66.67779e5.  May be simple but I just can figure it out.

Thanks J

0 Kudos
Message 1 of 10
(6,975 Views)

You can use ChnCalculate to do conversions by some script code

Option Explicit  'Forces the explicit declaration of all the variables in a script.
data.Root.Clear
dim chObj : set chObj = data.Root.ChannelGroups.Add("group").Channels.Add("TxtVal",DataTypeString)
chObj.Values(1) = "6667779999"
chObj.Values(2) = "4343"

Call ChnCalculate("Ch(""group/lngVal"")= CDbL(Ch(""group/TxtVal""))")

 Be aware of the fact that the numbers might look currious because they will not fit into an double value. You have to switch your format to avoid numbers to show up in scintific way.

0 Kudos
Message 2 of 10
(6,965 Views)

Hi J,

 

If we can solve this in the DataPlugin (*.uri file), then that's where we should solve it.  If that really isn't possible, I can send you a script approach to copy the contents of a string channel into a numeric channel.

 

Would you please send me several data files and your current *.uri file that you're using?

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 10
(6,956 Views)

 

Here is the URI I have to load the file.  The group is group 7 in the portal and the channel name is "Policy Request Date".  what I plan on doing with this is below.  I use the Month(1-12) for another purpuse in my script.  Could the URI include this as well?  I thought I was kinda stuck with what the wizard creates.

 

SET CH_source = Data.Root.ChannelGroups(7).Channels("Policy Request Date")

Set CH_MT = Data.Root.ChannelGroups(7).Channels.Add("Policy Request Date-Month",DataTypeFloat64)

For i = 1toCH_source.Size

CH_MT(i) =Month(CH_source(i))

NEXT

' Call ChnCharacterAll()

' Call ChnNovHandle("[7]/Policy Request Date-Month","[7]/Policy Request Date-Month","Delete","XY",1,1,0)

' Classbegin = chnvalmin("Policy Request Date-Month") -.5

' ClassEnd = chnvalmax("Policy Request Date-Month") +.5

' ClassWidth = 1

' Call ChnHistogram("[7]/Policy Request Date-Month","[7]/Policy Request Date-Month_ClassMean","[7]/Policy Request Date-Month_SampleCount","BeginEndWidth","absolute")

0 Kudos
Message 4 of 10
(6,952 Views)

Sorry forgot to add the attachment.

0 Kudos
Message 5 of 10
(6,949 Views)

Hi J,

 

You also need to send me at least one data file-- ideally several.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 10
(6,947 Views)

Sure.... Here is everything I am doing.  Any suggestions to speed anything up would be welcomed.

Thanks!

 

0 Kudos
Message 7 of 10
(6,944 Views)

Hi J,

 

OK, I got your DataPlugin to load the Excel data file, and I got your main script to run to do all the status sorting.  Based on the number of rows and columns in your data file, I'm going to recommend that we do any string to numeric conversion inside DIAdem and not in the DataPlugin.

 

Now, you said in your first post that you want to convert "6667779999" or "4343".  So, what do you want to convert them "to"?  What do you want to do with the converted values?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 8 of 10
(6,937 Views)

Ok, so the original data is a Text value and I would like it to be numeric file but I need it complete numbers in otherwords, when working with the larger set I need to keep it the way it is "6667778888" needs to stay that way and not turn into a different format.(like 66.677e5 or similar).  Hope that helps if not let me know.

0 Kudos
Message 9 of 10
(6,925 Views)
Solution
Accepted by Jcheese

Hi J,

 

A number like 66.6778888e5 can be displayed as 6667778888 in a VIEW or REPORT table or text box or REPORT graph axis by using the correct display format string-- in this case "d".  Where do you want the 6667778888 numbers to show up that way in DIAdem, exactly?  If you want to see it in a VIEW table, you will need to choose the "Selected Channels" radio button first in the configuration dialog, and only then will you be able to choose a display format string such as "d" for that column.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 10 of 10
(6,921 Views)