Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
FrankGrimm
Partner - Creator
Partner - Creator

extract parts from a textfile

Hello together,

 

i have a textfile i have to work with.

But there are "bad" parts which interrupt my process. (see green marks in the example).

The "bad parts have an defined begin and a defined end.

Begin:<TableField type="Table

End: </TableField>

With textbetween() can i read this parts, but how can i delet this "bad" parts?

How often this parts appear in a text is flexible.

Thanks for your help!

 

Labels (3)
1 Solution

Accepted Solutions
rubenmarin

Hi, you can try a script like this one:

Data0:
LOAD Filecontent as Data
From...;

LET vIter = 1;

Do
	LET vIterPre = $(vIter)-1;

	Data$(vIter):
	Noconcatenate LOAD 
		Mid(Data,1,Index(Data,'<TableField type="Table')-1) 
		& Mid(Data,Index(Data,'</TableField>')+Len('</TableField>')) 
	as Data Resident Data$(vIterPre);
  
	Drop table Data$(vIterPre);
	
	LET vData= Peek('Data',0,'Data$(Iter)');
	LET vIter=$(vIter)+1;
	
Loop While Index('$(vData)','<TableField type="Table');

 

View solution in original post

3 Replies
rubenmarin

Hi, you can try a script like this one:

Data0:
LOAD Filecontent as Data
From...;

LET vIter = 1;

Do
	LET vIterPre = $(vIter)-1;

	Data$(vIter):
	Noconcatenate LOAD 
		Mid(Data,1,Index(Data,'<TableField type="Table')-1) 
		& Mid(Data,Index(Data,'</TableField>')+Len('</TableField>')) 
	as Data Resident Data$(vIterPre);
  
	Drop table Data$(vIterPre);
	
	LET vData= Peek('Data',0,'Data$(Iter)');
	LET vIter=$(vIter)+1;
	
Loop While Index('$(vData)','<TableField type="Table');

 

marcus_sommer

Did you try to load the file as xml ?

- Marcus

FrankGrimm
Partner - Creator
Partner - Creator
Author

Thanks a lot. A perfect solution! 

Frank