Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Hello @sunny_talwar
check attached Excel file
this is the source of my data
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.
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
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
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()?
I've only observed it with MapSubstring().
Thank you Rob!!