User Tools

Site Tools


transformations:convert

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
transformations:convert [2018/01/23 00:02] – [Everything to text] dmitrytransformations:convert [2021/04/02 23:27] craigt
Line 1: Line 1:
-===== Convert Data Types ===== +{{ transformations:ConvertDataTypesAction.png}} 
- +====== CONVERT DATA TYPE ====== 
-This transformation converts values of one type (e.g. text) to another type (e.g. number). There are 3 modes:+CategoryTransform / Basic\\
  
 +\\ 
 +=====Description=====
 +This action converts values of one type (e.g. text) to another type (e.g. number). There are 4 modes:\\
 +\\ 
 ====Text to date==== ====Text to date====
-In this mode text values that look like a date are converted into number dates. A date format must be specified. All text values that match the specified format are converted to number dates. For instance:+In this modetext values that look like a date are converted into number dates. A date format must be specified. All text values that match the specified format are converted to number dates.    
 +The format notation is the same as for the [[syntax:functions:format|format()]] function.\\
  
-Format: M/d/yyyy+\\  
 +====Text to number==== 
 +In this mode, text values that look like a number are converted into numbers.\\
  
-^  Before (text)  ^  After ^ Comment ^ +\\  
-| 12/31/2017  |   43100 | Corresponds to December 31st2017+====Everything to text==== 
-| 12-31-2017  | 12-31-2017  | No conversion happened as the text value didn't match the specified format. |+In this modetext values remain unchanged and non-text values are converted into textNumbers are formatted as per the specified format.\\
  
-The format notation is the same as for the [[syntax:functions:format|format()]] function.+\\  
 +====Empty to text or a number==== 
 +In this mode, empty values are replaced with the static text or number value specified.\\
  
-====Text to number==== +\\ 
-In this mode text values that look like a number are converted into numbers. For instance:+=====Use cases===== 
 +  * Convert text-based dates to numeric date values for use in date-based calculations downstream. 
 +  * Convert numbers originally captured as text to true numeric values. 
 +  * Recode "blank" values as specific text or number values.
  
-Decimal separator: Point +\\  
- Before (text)  ^  After Comment +=====Action settings===== 
-1000    1000 |   +^Setting^Description
-1,000  1,000 No conversion happened as the text value has different decimal separator. | +|Columns to convert|Select the column(s) from the dataset to apply the value conversion to.
-10.00     10 |   +|Conversion|Select the conversion mode to use.  Options:  //Text to Date////Text to Number//, //Everything to Text//, and //Empty to text or number//.| 
-$1000  $1000 No conversion happened as the text value is not recognized as a number. |+|If conversion fails|Select how EasyMorph will respond when the selected conversion type cannot be applied to values.\\  Options:  //Keep original value// (the original, unmodified value is kept), //Generate error// (an error message is inserted\\ into the cells where conversion failed), or //Halt execution// (the action will display an error flag).| 
 +\\  
 +====Text to Date settings==== 
 +^Setting^Description^ 
 +|Format<sup>*</sup>|Enter the date format the current text dates are using (e.g. yyyy-MM-dd).  Use the //Detect// button to populate this field with any date formats found within the column.| 
 +<sup>*</sup> Setting can be specified using a [[:parameters|parameter]].\\ 
 +\\  
 +====Text to Number settings==== 
 +^Setting^Description^ 
 +|Decimal separator|Select what character is used to define decimal places in the source text values.  Options:  //Point// or //Comma//.| 
 +\\  
 +====Everything to Text settings==== 
 +^Setting^Description^ 
 +|Number format|Select the output format for the converted text values (e.g., selecting "100%" will multiply numbers by 100 and append "%").| 
 +\\  
 +====Empty to text or number settings==== 
 +^Setting^Description^ 
 +|Value<sup>*</sup>|Enter a static text or numeric value to convert empty cells to.| 
 +<sup>*</sup> Setting can be specified using a [[:parameters|parameter]].\\
  
  
-====Everything to text==== +\\  
-In this mode text values remain unchanged and non-text values are converted into text. Numbers are formatted as per the specified formatFor instance:+=====Examples===== 
 + 
 +**Text to date example:** 
 + 
 +>  Format: M/d/yyyy 
 + 
 +^Before (text)  ^After ^Comment ^ 
 +|12/31/2017 |  43100 | Corresponds to December 31st, 2017. | 
 +|12-31-2017 |12-31-2017  | No conversion happened as the text value didn't match the specified format. | 
 + 
 +\\  
 +**Text to number example:** 
 + 
 +>  Decimal separator: Point 
 + 
 +^Before (text)  ^After ^Comment ^ 
 +| 1000  |  1000 |   | 
 +| 1,000  |1,000 | No conversion happened as the text value has different decimal separator
 +| 10.00  |  10 |   | 
 +| $1000  |$1000 | No conversion happened as the text value is not recognized as a number
 + 
 +\\  
 +**Everything to text example:** 
 + 
 +^Format  ^Before ^After ^ 
 +|  100%  |  10|1000% | 
 +|  1'000.00  |  5500 |5,500.00 | 
 +|  yyyy/MM/dd  |  22335 |1961/02/23 |
  
-Number format100%+\\  
 +=====Shortcuts===== 
 +Fast ways to create the action:\\ 
 +  *Right-click on a column heading, and select "Convert data type", then select the conversion mode from the submenu. 
 +  *Click the drop-down arrow in a column heading and select "Convert data type", then select the conversion mode.
  
-^  Before  ^  After (text) ^ Comment ^ +\\  
-|    10  | 1000% |   | +=====See also===== 
-| $1000  $1000 | No conversion happened as the value is not a number. | +  * [[syntax:types|Type system in EasyMorph]] 
-| ABcd   | ABcd  | No conversion happened as the value is not a number. | +  * [[syntax:functions:astext]] 
- TRUE  | TRUE  | Booleans are converted to text.  | +  * [[syntax:functions:asnumber]] 
-|#Error  | Error | Errors can be converted into text too.  | +  * [[syntax:functions:format]]
-|  43100 | 4310000%  | This value is probably a date (#2017-12-31) but since the specified number format is percentage the value was converted into percentage formatted text. A date format should've been used.  |+
transformations/convert.txt · Last modified: 2023/10/05 17:01 by dmitry

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki