Qlik Community

QlikView Documents

Documents for QlikView related information.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Mapping hex code to text

jeroen_wagner
Contributor

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?

jeroen_wagner
Contributor

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.

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;

MVP & Luminary
MVP & Luminary

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

jeroen_wagner
Contributor

Nice one

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..

MVP & Luminary
MVP & Luminary

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

jeroen_wagner
Contributor

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

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