Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
neerajthakur
Creator III
Creator III

Spliting Data

Hi All,

 

I have a field having data in this form "field1":[null,"111","222","qwerty"],"field2":107,"field3":"NA","field4":[null,"11"]

How can I split this data using subfield and purgechar,

Expected result : 

Row 1 : field1:null,111,222,qwerty

Row 2: field2:107

Row 3: field3:NA

Row 4: null,11

Thanks & Regards,
Please Accepts as Solution if it solves your query.
Labels (3)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

try below

 

temp:
Load
if(index(Row,':'),SubField(Row,':',1),Peek('FieldLabel')) as FieldLabel
,PurgeChar(if(index(Row,':'),SubField(Row,':',2),Row),'[]') as Value
;
Load
subfield(@1,',') as Row
;
LOAD
@1
FROM [lib://AttachedFiles/blank.txt]
(txt, codepage is 28591, no labels, delimiter is '\t', msq);


Load FieldLabel,Concat(trim(Value),',') as RowValues
Resident temp
Group by FieldLabel;
Drop table temp;

exit Script;

 

vinieme12_0-1676974734497.png

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

5 Replies
brunobertels
Master
Master

hi try keepcher rather than purgechr :

 

keepchar(YourField,',:0123456789abcdefghijklmnopqrstuvwxyz' )

 

brunobertels_0-1676894196640.png

 

neerajthakur
Creator III
Creator III
Author

It will work only to an extent, now how will I split the data into different rows ? as using subfield(A,',') will split this newly created value too.

 

Table:

Load A from Table1;

This field A contains data in above format. I want it to split it now into different rows like field1,field2,field3,field4

Thanks & Regards,
Please Accepts as Solution if it solves your query.
MayilVahanan

Hi

Might be, try like below

Load * Where A1 <> 'field';
LOAD A, 'field'&PurgeChar(SubField(Replace(A, '"',''), 'field'),'][') as A1
FROM
[209779.txt]
(txt, codepage is 28591, embedded labels, delimiter is '\t', msq);

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
neerajthakur
Creator III
Creator III
Author

Hi @MayilVahanan 

Field name can be anything I used field1 , .... as example here cannot use it a delimiter

Thanks & Regards,
Please Accepts as Solution if it solves your query.
vinieme12
Champion III
Champion III

try below

 

temp:
Load
if(index(Row,':'),SubField(Row,':',1),Peek('FieldLabel')) as FieldLabel
,PurgeChar(if(index(Row,':'),SubField(Row,':',2),Row),'[]') as Value
;
Load
subfield(@1,',') as Row
;
LOAD
@1
FROM [lib://AttachedFiles/blank.txt]
(txt, codepage is 28591, no labels, delimiter is '\t', msq);


Load FieldLabel,Concat(trim(Value),',') as RowValues
Resident temp
Group by FieldLabel;
Drop table temp;

exit Script;

 

vinieme12_0-1676974734497.png

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.