Questions tagged [unpack]

A function in several scripting languages for unpacking binary data into native types for the language in question. The opposite of the 'pack' function. For the Python concept, use 'iterable-unpacking'. This tag should be used with a programming language tag as well. While also used as directive or pragma in some compilers to ignore standard variable alignment for data aggregates (i.e. struct), do not use this tag for posts on that subject.

The unpack function parses a binary string into several variables with types that are native to the language in question. The binary string usually matches the machine-level representation that you would see in a C . The inverse operation is .

For Python use .

Most versions of unpack and pack functions use a format or template that specifies the byte by byte layout of the data being copied out of or put into the memory area containing the binary representation.

Both functions allow the use of C or C++ routines with complex data structures to be used with the scripting language in order to improve application performance or to perform operations and actions not available in the scripting language.

Documentation:

615 questions
-1
votes
1 answer

Unpacking UDP packets python

I am receiving UDP packets over wifi running a simple python script on a PC. The server and the PC are in the same subnet. The server is sending 15 uint_8 (4 bytes each) every 20 ms or so. The data received seems to be corrupted (non Hex values).…
Venkat
  • 1
  • 1
-1
votes
1 answer

C# pack.xz garbage after end of pack archive

I have a C# program that should download a file from the internet and extract it. The file is a .pack.xz file, i have no problem extracting the .xz, i tried even manually checking the checksum of the file and it was downloaded correctly. For…
LifeRewind
  • 19
  • 6
-1
votes
1 answer

Unpacking a list/string of hex values into integers

I'm trying to unapck a list from hex to integers in python. So for example: hexValues = '\x90\x82|uj\x82ix' decodedHex = struct.unpack_from('B', hexValues,0) print decodedHex Which would print (144,) and nothing else. Is there any way I can loop…
cryptiblinux
  • 29
  • 3
  • 12
-1
votes
1 answer

Why a function starts with @ in php ? like @unpack(xxx)?

$block_header = @unpack('Sc_size/Su_size/Lchecksum', fread($this->fp, 8)); What does this mean ?
-1
votes
1 answer

Searching the proper format in php unpack function

The output is the result of the codes: $bytes= fread($handle,"32"); print_r(unpack("La/fb/fc/fd/fe/ff/fg/fh",$bytes)); Array ( [a] => 20150416 [b] => 1.0499999523163 [c] => 1.25 [d] => 1.0299999713898 [e] => 1.1900000572205 [f] =>…
showkey
  • 482
  • 42
  • 140
  • 295
-1
votes
3 answers

How can I use the struct library in python to pack a double into two uint32's

So this is what I would like to do: I have a double and I need to pack it into binary data and then get the upper four bytes and store them into a uint32 (it has to do with a device driver). I already do this with floats: import struct import numpy…
Voltage Spike
  • 162
  • 4
  • 15
-1
votes
2 answers

unpack list of lists in for loop not working

I have: master_list = [['001', '15\n', '963789', '40\n', '741239', '80\n', '985697', '80\n', '854698', '35\n', '965874', '10\n'], ['002', '25\n', '326574', '65\n', '944223', '40\n', '312689', '45\n', '225869', '80\n', '789654', '35\n'], ['003',…
Robert
  • 10,126
  • 19
  • 78
  • 130
-1
votes
2 answers

unpacking a list in python

Somewhere I saw a piece of code where you can unpack a list in a for loop. Let's say that I have a list: row = ['001', '15\n', '963789', '40\n', '741239', '80\n', '985697', '80\n', '854698', '35\n', '965874', '10\n'] what would be the for loop to…
Robert
  • 10,126
  • 19
  • 78
  • 130
-1
votes
3 answers

Python ValueError : too many values to unpack, solution?

Im getting this error and i have no idea what it means, i can get the program to print the files from there values but its just a long incoherent now im trying to get it to print it in an organized manor and thats where the issues arise. import os…
-1
votes
1 answer

Create a package python

I've created a TAR with some xml and classes, In another server i need to put those files in various directories, something like an installable, is possible? Using CentOS Thanks
Marco Herrarte
  • 1,540
  • 5
  • 21
  • 42
-1
votes
1 answer

How can I add a class file into a jar file inside another jar

I have a jar file which contain another jar inside: abc.jar --> a.class, b.jar, c.txt which a.jar --> x.class, y.class I want to add new class file z.class into a.jar & return abc.jar with updated a.jar 1 way is that extract & pack again. Can I do…
Nishantha
  • 87
  • 1
  • 8
-2
votes
1 answer

Parse bit-packed numbers from hex string in Python

I am unfamiliar with struct.pack() and unpack(). I have a string '08d16113' representing a 4 byte sequence. I need to: Convert it to a 32 bit number. Convert the number to 2 decimal integers, such that the first number is derived from the first 20…
-2
votes
1 answer

Replacement of the time zone in the file

I have 2 files created in Linux and to work in Linux. When I go on the Internet, the time automatically changes (time zone) on Asia (Shanghai) and this is due to these files. I found (with winhex) that there is a file…
-2
votes
2 answers

Unpacking list in Python - ValueError: not enough values to unpack

I test my script just printing return value of .split: for f in os.listdir(): f_name, f_ext = os.path.splitext(f) print(f_name.split('-')) and it shows me what I'd like to see - lists with 3 strings in each. ['Earth ', ' Our Solar System ',…
-2
votes
2 answers

Unpack a single element from a list of lists python

I have zipped some data into as following: list1 = [1,33,3] list2 = [2,44,23] list3 = [[3,4,5,6],[3,4,5,3],[4,5,3,1]] list4 = [4,34,4] data = [list(x) for x in zip(list1, list2, list3, list4)] However, list3 is a list of lists. So the output ended…
Victor
  • 9
  • 2
1 2 3
40
41