Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a LOAD script with many columns.
I have to check if one of them (COLUMN3) contains the word "cat", and then I have to create a new column with the value "yes" if COLUMN3 contain "cat", "no" if COLUMN3 doesn't contain "cat".
How can I do that with a mapping table?
Hi @ValeriaBonini it can be easily done using the if and else condition on the respective column, for instance
if (Column3 ='cat', yes, no) as New_column3
use single quotes and normal if condition if you want to do a simple match and wildmatch if you want to use the case insensitive version for multiple characters.
Why are you referring to a mapping table, are there other searchstrings than just 'cat'?
im not sure why you mention “mapping table”
but, you can try this in script
If “cat” can be in any place of the field value
if (wilmatch(Column3,'*cat*'),' yes', 'no') as New_column3
if have to start with “cat”
if (wilmatch(Column3,'cat*'),' yes', 'no') as New_column3
or
if (left(Column3,3)='cat'),' yes', 'no') as New_column3
Hope this works for you
best,
Hi, yes I have many strings to check (5)
I have many strings to check
Hi
Try like below
MapTable1:
Mapping Load *, 'Yes' as Value2 inline
[
Value1
Cat,
Dog
];
Load *, ApplyMap('MapTable1', COLUMN3 , 'No') as COLUMNNew from ursource;