Qlik Community

QlikView Documents

Documents for QlikView related information.

Mapping hex code to text

Partner
Partner

Mapping hex code to text

Here a test file I created for a client, who needed to import data from a database, but text was only available in hex code.

Using an inline table, hex text is converted to plain text.

Note: Edited by Community Moderator for clarity.

Attachments
Comments
MVP & Luminary
MVP & Luminary

Interesting idea but how can you be sure that the 2 Byte replace hits the right position all time?

0 Likes
Partner
Partner

Hex code is 2 Byte code always, so you might have to do an alignment to start of, but once you start at the right position, the process will continue on the right path.

0 Likes
flipside
Valued Contributor II

Another way, create a function in Macro script ...

function HexToDec(num)
  HexToDec = clng(num)
end function

... then call in script ...

Data:
LOAD Form_Text,
rowno() as FormID,
Chr(HexToDec('&h' & mid(Form_Text,iterno()*2-1,2))) as letter
while iterno()/2<len(Form_Text);
LOAD * INLINE [
Text Number,Language,Number of Lines,Form_Text
....

.. and then rebuild the string ...

FinalData:
Load Form_Text, concat(letter,'',FormID) as Decode resident Data group by Form_Text;

0 Likes
MVP & Luminary
MVP & Luminary

I think a combination of MapSubString and while iterno()/2 would be the best case..

0 Likes
Partner
Partner

Nice one

0 Likes
MVP & Luminary
MVP & Luminary

Not necessarily since your Mapping Load is incomplete, let's say text in hex is: 22100A

the MapSubString will replace "21" first (top down processing), which would be wrong..

0 Likes
MVP & Luminary
MVP & Luminary

However, I think it would be more save to have a complete Mapping Table 00 to FF..

0 Likes
Partner
Partner

I agree... this was enough for the customer however, as it was all general text based data.

0 Likes
Version history
Revision #:
1 of 1
Last update:
‎2016-01-21 07:11 AM
Updated by: