How to handle special characters between a Statistica Data Function and Spotfire Analyst

How to handle special characters between a Statistica Data Function and Spotfire Analyst

book

Article ID: KB0070415

calendar_today

Updated On:

Products Versions
Spotfire Statistica 14.0.1 and higher
Spotfire Analyst 12.5 and higher

Description

When data is read into Spotfire which includes special character such as μ (Mu or Micro) or ¹ (Super Script 1) and then used on input from Spotfire to Statistica, the data is read by Statistica as a ? character (question mark).  In other words, Statistica cannot translate these types of characters but instead places a ? for any special character it cannot translate.

For example, below is data loaded into Spotfire from a SBDF data file has special characters not seen on a typical keyboard:

Data loaded into Spotfire with special characters


When a Statistica Data Function is used to pass data from Spotfire to Statistica (used as input) and then the data is returned back to Spotfire (used as output) we see ? in place of these special characters: 

Special characters show as ? in Statistica

 

Environment

OS: Windows

Resolution

Part 1 -  Spotfire - Use Spotfire RXReplace function to add a calculated column with html encoding

1.  In the data canvas, go to Data>>Add Calculated column...:

Add calculated column

2.  Add the expression using the RXREPLACE, with the Test_Method as the column:

Calculated column


Text of the expression:
RXReplace(RXReplace(RXReplace(RXReplace([Test_Method],"µ","%micro","g"),"º","%deg","g"),"²","%sup2","g"),"¹","%sup1","g")


3.  Click the OK button and the calculated column will be added and the additional column will appear with the corresponding encoding:

Calculated Column encoding


Part 2 - Statistica - The workspace used as a Statistica Data Function uses the RE_REPLACE function

1.  Create a workspace to include a spreadsheet and a Transformations of Variables node

      a.  Spreadsheet:

Statistica spreadsheet with calculated column names


      b.   Transformation of Variables node:

Transformation of Variable node with RE_REPLACE

Text of the formulas:
Test_Method=RE_REPLACE(RE_REPLACE(RE_REPLACE(RE_REPLACE(Test_Method_Encode,"%micro","µ","g"),"%deg","º","g"),"%sup1","¹","g"),"%sup2","²","g")
temperature_offset=RE_REPLACE(RE_REPLACE(RE_REPLACE(RE_REPLACE("temperature offset_Encode","%micro","µ","g"),"%deg","º","g"),"%sup1","¹","g"),"%sup2","²","g")




Part 3 - Register and configure the Statistica workspace as a Statistica Data Function

1.  Add the data function to Spotfire Analyst:

Add registered Statistica workspace as data function



2.  Configure the data function's definition:  

   a.  Input Definition:

Data Function Definition - Input

b.  Output Definition:

Data Function Definition - Output



3.  Edit the data function parameters:

   a.  Input:

Data Function input parameters

   b.  Output:

Data Function - Output parameters

4.  Run the data function and view the output.  The output, below, shows the html code translated to the associated special character:

Final output of data table from data function

Note:  Attached, at the bottom, is the DXP shown in this example (SpecialCharacters Translation.dxp).  

Issue/Introduction

Special characters used with Statistica Data Functions (in Statistica these are Statistica Workspaces) are changed to '?' which renders the data unknowable.

Additional Information

ASCII to HTML encoding:
https://www.ee.ucl.ac.uk/~mflanaga/java/HTMLandASCIItableC1.html

ASCII codes
https://support.microsoft.com/en-us/office/insert-ascii-or-unicode-latin-based-symbols-and-characters-d13f58d3-7bcb-44a7-a4d5-972ee12e50e0

Statistica's RE_REPLACE formula
https://docs.tibco.com/pub/stat/14.1.0/doc/html/UserGuide/Default.htm#5-working-with-spreadsheets/spreadsheet-formulas-regular-expression-functions.htm?Highlight=re_replace

Spotfire's RXReplace function
https://support.tibco.com/s/article/Tibco-KnowledgeArticle-Article-43748

HTML coding for characters:
https://reeddesign.co.uk/test/character-entities.html

 

Attachments

How to handle special characters between a Statistica Data Function and Spotfire Analyst get_app