Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All ,
How to convert a single row into multiple based on a delimiter condition in one particular column ?
Field Person has values delimited . But Delimiter type is not fixed .
Thanks & Regards
Shekar
Not sure how can you improve this, but may be this
SET vChange = Replace(Replace(Replace(Replace(
Replace(Replace(Replace(Replace(
Replace(Replace(Replace(Replace(
Replace(Replace(Replace(Replace(
Replace(Replace(Replace(Replace(
Replace(Replace(Replace(Replace(
Replace(Replace(Replace(Replace(
Replace(Replace(Replace(
$1, '~', ','), '!', ','), '@', ','), '#', ','), '$', ','), '%', ','), '^', ','), '&', ','), '*', ','), '(', ','), ')', ','), '_', ','), '+', ','), '-', ','), '=', ','), Chr(39), ','), ';', ','), '"', ','), ':', ','), '}', ','), '{', ','),
']', ','), '[', ','), '\', ','), '|', ','), '?', ','), '>', ','), '<', ','), '.', ','), '/', ','), ' ', ',');
LOAD *,
SubField($(vChange(Person)), ',') as NewPerson;
LOAD * INLINE [
Doornbr, Date, Person
22456, 12/12/2017, "Sam,Krish,Tony"
22457, 13/12/2017, "Sam,Bill.Munoj"
22458, 14/12/2017, Murphy#Linda
22459, 15/12/2017, Numerov
22459, 12/12/2017, Joy.Gracy
22461, 14/12/2017, Tina#Deva
22461, 14/12/2017, Tina#Deva
];
Hi,
you can try like this?
Fact:
load *, Trim(SubField(SubField(SubField(Person, ','), '.'),'#')) as Person_Revised;
LOAD Doornbr,
Date,
Person
FROM
(ooxml, embedded labels, table is AreaA);
Concatenate
load *, Trim(SubField(SubField(SubField(Person, ','), '.'),'#')) as Person_Revised;
LOAD Doornbr,
Date,
Person
FROM
(ooxml, embedded labels, table is AreaB);
Hope this helps to you ![]()
Close this thread by Marking helpful and correct. if might useful for other who is having similar issue. Tks
Regards,
Deva
Hi,
Can you please try this:
Table:
LOAD DISTINCT
Doornbr,
Date,
SubField(SinglePerson2,'.') as SinglePerson;
LOAD
Doornbr,
Date,
SubField(SinglePerson1,'#') as SinglePerson2;
LOAD
Doornbr,
Date,
SubField(Person,',') as SinglePerson1;
LOAD * INLINE [
Doornbr,Date,Person
22456,12/12/2017,"Sam,Krish,Tony"
22457,13/12/2017,"Sam,Bill.Munoj"
22458,14/12/2017,"Murphy#Linda"
22459,15/12/2017,"Numerov"
22459,12/12/2017,"Joy.Gracy"
22461,14/12/2017,"Tina#Deva"
22461,14/12/2017,"Tina#Deva"];
Please let me know if it works,
Cheers,
Luis
Hi Shekhar,
Try like this:
load Doornbr,
Date,
subfield(replace(replace(replace(Person,',','|'),'#','|'),'.','|'),'|') as Person
from excel
Br,
KC
Hi Dev ,
Thanks for reply . Your solution is working fine with above sample data . But the problem i am facing is that delimiters are not just comma , hash or dot . Actually it varies within other special characters like (* , & , ^ , @ etc ) .
So my requirement is to handle any of the delimiter dynamically .
Thanks & Regards
Shekar
Thanks for reply Luis . But in real data field delimiters
are not just comma , hash or dot . Actually it varies within other special characters like (* , & , ^ , @ etc ) .
So my requirement is to handle any of the delimiter dynamically .
Hi,
Is it possible for you to list all possible delimiters in a string or characters?
Such as this for example: ~!@#$%^&*()_+-=';":}{][\|?><,./
This is important because for example, is a space or a dash or an apostrophe or a number a delimiter?
There could be a for-next loop that checks for all possible or not possible characters... but something needs to be provided
Cheers,
Luis
.... Actually You have rightly mentioned . Apart from these ~!@#$%^&*()_+-=';":}{][\|?><,./ ,I noticed Space and hyphen as well .
Yes above all are my possible delimiters .
Hi Shekar,
try to use this:
subfield(Replace(Person,PurgeChar(Person,'abcdefghijklmnopqrstuvwxyz'),','),',') as YourNewPerson
Thanks.
BR
Martin
I am not really sure if that works .Please attach sample .