cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar

dt:ColName << Set Data Type("Numeric") deletes values that have a decimal point

I have a Data table with some data that I imported from a text file, which contains columns that by default have Data Type == Character and Modeling Type == Nominal. These columns contain numbers, of which some have a decimal point and some digits behind the decimal point. I wish to transform these columns to Numeric, Continuous, Engineering SI, but I have run into some strange behavior. Namely, in some cases the values in the column which contain a decimal point will be deleted (their value is set to ".").

 

I have tried two approaches:

 

Changing the columns manually using Column Info:

- If I change all three fields at once to Numeric, Continuous, Engineering SI, and then click "Apply", then the values that contain a decimal point will be reset to "."

- If I press "Apply" after changing each field (so 3 times total), then the values are correctly formatted and everything works. 

 

Changing the columns using JSL: (This is what I actually want to do)

My code to set all three fields at once:

dt = Current Data Table();
dt:ColumnName <<  Set Data type( "Numeric" ) << Set Modeling Type( "Continuous" ) << Set Format( "Engineering SI", 12, 5);

This will reset all values in the column ColumnName to ".". I have also tried using column(dt, "ColumnName") instead of dt:ColumnName, and to only set one field at a time, but the result is the same. The code seems to run fine. It does write "Scriptable[]" to the terminal, but I haven't been able to find out what this means.

1 ACCEPTED SOLUTION

Accepted Solutions
pauldeen
Level VI

Re: dt:ColName << Set Data Type("Numeric") deletes values that have a decimal point

You are probably in Europe and your local is set to use , as the decimal seperator. Do a search and replace on the column first replacing . by , then your code should work.

View solution in original post

1 REPLY 1
pauldeen
Level VI

Re: dt:ColName << Set Data Type("Numeric") deletes values that have a decimal point

You are probably in Europe and your local is set to use , as the decimal seperator. Do a search and replace on the column first replacing . by , then your code should work.