Jump to content

converting raw values to decimal text file

I have data files that looks like it is containing unsigned integers in 4 byte little endian format. At least I assume they're unsigned, as they fit in the lowest byte and doing a straight decimal conversion gives a sensible value. I want to mess around with the data in a spreadsheet, but how do I do the conversion to text? Sounds like it should be simple, but I'm not sure even where to start.

 

Example data seen in hex editor: 7b 00 00 00 7d 00 00 00 77 00 00 00

I'd ideally like it converted to text decimal in a column:

123

125

119

 

Gaming system: R7 7800X3D, Asus ROG Strix B650E-F Gaming Wifi, Thermalright Phantom Spirit 120 SE ARGB, Corsair Vengeance 2x 32GB 6000C30, RTX 4070, MSI MPG A850G, Fractal Design North, Samsung 990 Pro 2TB, Acer Predator XB241YU 24" 1440p 144Hz G-Sync + HP LP2475w 24" 1200p 60Hz wide gamut
Productivity system: i9-7980XE, Asus X299 TUF mark 2, Noctua D15, 64GB ram (mixed), RTX 3070, NZXT E850, GameMax Abyss, Samsung 980 Pro 2TB, random 1080p + 720p displays.
Gaming laptop: Lenovo Legion 5, 5800H, RTX 3070, Kingston DDR4 3200C22 2x16GB 2Rx8, Kingston Fury Renegade 1TB + Crucial P1 1TB SSD, 165 Hz IPS 1080p G-Sync Compatible

Link to comment
Share on other sites

Link to post
Share on other sites

Using Python 2.7

test_values = [0x7b, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00]

for x in xrange(0, len(test_values), 4):
    int_value = 0
    int_value |= test_values[x]
    int_value |= (test_values[x+1] << 8)
    int_value |= (test_values[x+2] << 16)
    int_value |= (test_values[x+3] << 24)

    # Do something with int_value

But the general idea applies anywhere.

Link to comment
Share on other sites

Link to post
Share on other sites

9 minutes ago, Mira Yurizaki said:

Using Python 2.7

But the general idea applies anywhere.

I could write it in C (the only language I kinda know) but I haven't done it in forever, especially file operations, and don't have a compiler installed. Was hoping for an off the shelf solution. 

Gaming system: R7 7800X3D, Asus ROG Strix B650E-F Gaming Wifi, Thermalright Phantom Spirit 120 SE ARGB, Corsair Vengeance 2x 32GB 6000C30, RTX 4070, MSI MPG A850G, Fractal Design North, Samsung 990 Pro 2TB, Acer Predator XB241YU 24" 1440p 144Hz G-Sync + HP LP2475w 24" 1200p 60Hz wide gamut
Productivity system: i9-7980XE, Asus X299 TUF mark 2, Noctua D15, 64GB ram (mixed), RTX 3070, NZXT E850, GameMax Abyss, Samsung 980 Pro 2TB, random 1080p + 720p displays.
Gaming laptop: Lenovo Legion 5, 5800H, RTX 3070, Kingston DDR4 3200C22 2x16GB 2Rx8, Kingston Fury Renegade 1TB + Crucial P1 1TB SSD, 165 Hz IPS 1080p G-Sync Compatible

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×