Hitachi Vantara Pentaho Community Forums
Results 1 to 13 of 13

Thread: how to Convert Hexadecimal to Binary

  1. #1

    Lightbulb how to Convert Hexadecimal to Binary

    Hi ,

    I want to know with help of Pentaho How to create Hexadecimal to binary in PDI.

    Currently I am using PDI5.0 with Window 7 OS

    If any one know this then share your knowledge with us.

    Regards,
    Rushikesh

  2. #2
    Join Date
    Mar 2014
    Posts
    29

    Default

    Hi,
    Use "Integer.toBinaryString(Integer.parseInt(hexa,16))" in in user defined java class/user defined java Expression step to convert from Hexadecimal to Binary value.


    Thanks,
    Bhanu
    Last edited by Bhanuchandar; 11-21-2014 at 08:03 AM.

  3. #3

    Default

    Hi Bhanuchandar,

    Thanks for your suggestion.
    Can you provide me one sample transformation of User Defined Java Class with this thing .
    So that I will use that one in my transformation because I never used user Defined Java class

    Regards,
    Rushikesh

  4. #4
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Keep it simple
    Attached Files Attached Files
    So long, and thanks for all the fish.

  5. #5

    Default

    hi Marabu,

    Thanks for providing the sample ktr but in this ktr we are getting only hexadecimal to decimal ouputbut I want in binary output .

    Can you provide such ktr those who get binary output while I providing hexadecimal input.

    Regards,
    Rushikesh

  6. #6
    Join Date
    Mar 2014
    Posts
    29

    Default

    Hi,
    Replace this code "Integer.toBinaryString(Integer.parseInt(hex, 16))" in user defined java step to get binary converted value.


    Bhanu

  7. #7

    Default

    Hi,

    Thanks you very much Bhanuchandar and Marabu .It is working properly.Today I learned new one component UDJE Pentaho
    from both of you. But I want to convert (969C9245DE90C78012E4792416AF82F9F9651AB5FDCF70D26ED8188D8DA9C2BC) this hexadecimal number into binary form then UDJE not working .But for a small number it is working fine.

    Kindly provide some suggestion

    Regards,
    Rushikesh
    Last edited by rushi.nasre@gmail.com; 11-24-2014 at 05:44 AM.

  8. #8

    Default

    Hi everyone

    I've used the step calculator -> Hex to byte decode of string A, but it gives me random extra values. For example, the original data 25 50 44 46 2d 31 2e 34 0a 25 c7 ec 3f a2 0a , when hex encoded and then transformed using that step results in 25 50 44 46 2d 31 2e 34 0a 25 c7 ec 3f a2 0a 35 (byte to hex translated in notepad++).
    The idea behind this is to save a bytea stored file from a database, encoded in hex in the query, into a file.

    Any idea or sugestion?

    Regards
    Alexis

  9. #9
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Quote Originally Posted by rushi.nasre@gmail.com View Post
    But for a small number it is working fine.
    You can use class BigInteger to binary encode arbitrary size hex strings.
    Attached Files Attached Files
    So long, and thanks for all the fish.

  10. #10
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Quote Originally Posted by alexisechague View Post
    Any idea or sugestion?
    I suggest you prepare a transformation (Data Grid, Calculator) to demonstrate the behavior.
    So long, and thanks for all the fish.

  11. #11

    Default

    Quote Originally Posted by marabu View Post
    I suggest you prepare a transformation (Data Grid, Calculator) to demonstrate the behavior.
    About the problem that I mentioned earlier, here I put the database hex string to binary test using calculator (the final step is an script that is public available to put the byte stream in a file).
    The problem is that the calculator inserts generates extra values. Then, when running the transformation, in the result file you can find extra or mistranslated values; the first of them is in line 30, col 1 where a 9c is changed by a 3f. I'm using notepad++ with Hex editor view plugin. I've uploaded also the string file in a more readable format with CR every 32 characters.
    Attached Files Attached Files

  12. #12

    Default

    I have the same problem, I tried all the solution tried here and not works for me, any Idea??

  13. #13

    Default

    I tested this transformation but doesn't work for. Calc are wrong?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.