• Hex 2 dec conversion

    From Robert Vanpass@21:1/5 to All on Wed Dec 11 10:43:42 2019
    Hi,

    I have a .csv datafile with only 2-digit numbers in Hexadecimal form:
    6F
    73
    A5
    ...

    Is there a function in Gnuplot to convert these Hex numbers to Decimal form,
    or should it be written / how ?
    Another possibility would be to use an external commandline converter, something like Grepwin.
    Any idea what I could use for this ?

    Thanks

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Vanpass@21:1/5 to Robert Vanpass on Wed Dec 11 10:46:51 2019
    On Wednesday, December 11, 2019 at 7:43:44 PM UTC+1, Robert Vanpass wrote:
    Hi,

    I have a .csv datafile with only 2-digit numbers in Hexadecimal form:
    6F
    73
    A5
    ...

    Is there a function in Gnuplot to convert these Hex numbers to Decimal form, or should it be written / how ?
    Another possibility would be to use an external commandline converter, something like Grepwin.
    Any idea what I could use for this ?
    (I use Gnuplot 5.2.2 with Windows 10).


    Thanks

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Hans-Bernhard_Br=c3=b6ker@21:1/5 to All on Wed Dec 11 23:40:17 2019
    Am 11.12.2019 um 19:43 schrieb Robert Vanpass:
    Hi,

    I have a .csv datafile with only 2-digit numbers in Hexadecimal form:
    6F
    73
    A5
    ...

    That has surprisingly few commas and semicolons for a csv file :-)

    Is there a function in Gnuplot to convert these Hex numbers to Decimal form,
    No.

    There's the "send the data through an external program before use"
    function, but that's not terribly useful if you know no external program
    to do that kind of transformation job for you.

    In the Unix environment gnuplot originally grew up in, it would work
    roughly like this:

    plot "< awk -e '{printf \"%d\", strtonum (\"0x\" $1)) }' yourfile.csv"

    If you do have an 'awk' command around, that should actually work even
    on Windows.

    OTOH, if it's actual CSV and you're on Windows, you might want to follow
    the saying "when in Rome, do as the Romans" and just perform the
    transformation in you preferred spreadsheet program...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Karl Ratzsch@21:1/5 to All on Thu Dec 12 22:10:49 2019
    Am 11.12.2019 um 23:40 schrieb Hans-Bernhard Bröker:
    Am 11.12.2019 um 19:43 schrieb Robert Vanpass:
    I have a .csv datafile with only 2-digit numbers in Hexadecimal form:

    Is there a function in Gnuplot to convert these Hex numbers to Decimal form,
    No.

    Actually yes. Gnuplot understands hexadecimal (and octal), the
    number just needs a preceeding "0x" (or "0") marker. You just have
    to add it in your "using" statement, and then take advantage of
    gnuplot´s automatic type promotion:

    $dat << EOD
    11c 4
    12a 5
    133 4
    13f 6
    1aa 1
    EOD

    pl $dat us (("0x".strcol(1))*1):2 w l

    Admittedly, I was very doubtful too before seeing the above example
    actually producing a plot. ;)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Vanpass@21:1/5 to Robert Vanpass on Sat Dec 14 11:28:46 2019
    On Wednesday, December 11, 2019 at 7:43:44 PM UTC+1, Robert Vanpass wrote:
    Hi,

    I have a .csv datafile with only 2-digit numbers in Hexadecimal form:
    6F
    73
    A5
    ...

    Is there a function in Gnuplot to convert these Hex numbers to Decimal form, or should it be written / how ?
    Another possibility would be to use an external commandline converter, something like Grepwin.
    Any idea what I could use for this ?

    Thanks

    This works perfectly.

    Thank you so much !

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Vanpass@21:1/5 to Robert Vanpass on Sat Dec 14 23:19:39 2019
    On Wednesday, December 11, 2019 at 7:43:44 PM UTC+1, Robert Vanpass wrote:
    Hi,

    I have a .csv datafile with only 2-digit numbers in Hexadecimal form:
    6F
    73
    A5
    ...

    Is there a function in Gnuplot to convert these Hex numbers to Decimal form, or should it be written / how ?
    Another possibility would be to use an external commandline converter, something like Grepwin.
    Any idea what I could use for this ?

    Thanks

    Actually this is very intriguing to me:

    I tried to find this info myself in
    - the basic Gnuplot reference (Gnuplot helpfiles)
    - Gnuplot in action (Philipp K. Janert)
    - Gnuplot cookbook (Lee Phillips)
    but couldn't find anything like that.

    Where else could I look to learn tings like this ?
    (From time to time I'm really stuck, so you might see more posts from me...)

    Thanks

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)