Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ali_hijazi
Partner - Master II
Partner - Master II

what is wrong in my script?

Hello
I got a table called CASES_PEGA in which there is a field called PYDESCRIPTION which contains HTML tags
I'm trying to strip HTML codes and keep the text of PYDESCRIPTION field
I'm using the following script:

HtmlTag_Map:Mapping
LOAD DISTINCT
'<' & TextBetween('<' & SubField(PYDESCRIPTION, '<', IterNo()),'<','>') & '>' as HtmlTag,
'' as Substitute
Resident CASES_PEGA
While NOT IsNull(SubField(PYDESCRIPTION, '<', IterNo()));

Left Join(CASES_PEGA)
temp:
Load Distinct
CASE_ID
,MapSubstring('HtmlTag_Map', PYDESCRIPTION) as Field_Cleansed
Resident CASES_PEGA;

However I'm getting a GENERAL SCRIPT ERROR when executing the MapSubstring

kindly advise

I can walk on water when it freezes
14 Replies
sunny_talwar

Would you be able to share few rows of data to test this out? or share your logfile?
ali_hijazi
Partner - Master II
Partner - Master II
Author

Hello @sunny_talwar
check attached Excel file 

this is the source of my data

 

I can walk on water when it freezes
sunny_talwar

I am not sure what might be going on here... may be @rwunderlich can comment on this as he mentioned a similar problem here those uncaught store errors

For reference, I tried using this script

CASES_PEGA:
LOAD PYDESCRIPTION
FROM [..\..\Downloads\tages_2.xlsx]
(ooxml, embedded labels, table is Sheet1);

HtmlTag_Map:
Mapping
LOAD DISTINCT
	 '<' & TextBetween('<' & SubField(PYDESCRIPTION, '<', IterNo()),'<','>') & '>' as HtmlTag,
	 '' as Substitute
Resident CASES_PEGA
While NOT IsNull(SubField(PYDESCRIPTION, '<', IterNo()));

TRACE I AM HERE 1;

SET ErrorMode = 0;

FinalCASES_PEGA:
LOAD RowNo() as RowNum,
	 PYDESCRIPTION,
	 MapSubString('HtmlTag_Map', PYDESCRIPTION) as Field_Cleansed
Resident CASES_PEGA;

TRACE I AM HERE 2;

DROP Table CASES_PEGA;

SET ErrorMode = 1;

and even though I have set the errormode to 0, the script errors out.

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

MapSubstring() tends to throw errors when you use a mapping table that has keys longer than about 18k characters.  I'm not sure of the exact number, it seems to vary by a few hundred depending on circumstances.  In the example used in this thread there a number of keys > 26K chars. 

A simpler way, using a module function, to extract the contents of HTML elements can be found here. 

Qlikview Cookbook: Strip HTML From Text http://qlikviewcookbook.com/recipes/download-info/strip-html-from-text/

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

sunny_talwar

Thanks Rob!! You are the best.
Is this issue discussed in more details elsewhere? I would like to read more about it if possible.

Thanks,
Sunny
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Sunny,

Thanks for the compliment.  I have not seen it discussed anywhere except in my own head.  Here's a test script that demonstrates the issue.  Note that 18000 sometimes works for me, sometimes not. 20000 never works.

Map:
Mapping
LOAD
Repeat('A',RecNo())
,' '
AutoGenerate 20000
;

Data:
LOAD
'A' as Key
,MapSubString('Map', 'A') as Mapped
AutoGenerate 1
;

-Rob

sunny_talwar

This is strange... it did work for me with 20000, but started to error out after 20,500.... Is this a problem with just MapSubString() or have you noticed a similar issue with ApplyMap()?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I've only observed it with MapSubstring(). 

sunny_talwar

Thank you Rob!!