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
-2
votes
1 answer

How to unpack the tgz file present in a shell script?

I have a .sh build file which is basically a tar.gz file wrapped up with few lines of shell code. I know how to pack a tar.gz into shell like this, but how to do the reverse i.e., unpack the tgz file present in the .sh file? Thank you in advance!
-2
votes
1 answer

too many values to unpack in iterating tuple including tuple

metro_areas = [ ('Tokyo', 'JP', 36,933, (35.689722, 139.591593)), ('Delhi NCR', 'IN', 21.935, (38.52938, 77.39456)), ('Mexico City', 'MX', 30.194, (19.3452, -99.18284)), ('New York-Newark', 'US', 20.104, (40.80381,…
-2
votes
1 answer

Value Error in if statement in python. Too many values to unpack

File "game.py", line 81, in File "game.py", line 33, in start if a == "User name or Password is incorrect!": ValueError: too many values to unpack (expected 2) Here is the code generating the error: choice = input("> ") if…
-2
votes
1 answer

How to unpack a list in a dataframe

First time posting, newbie to python. I have a data frame consisting of 3 columns: ['ID', 'date', 'profit_forecast'] 'ID': is product ID 'date': start date 'profit_forecast': a list containing 367 items, each item is a profit forecast for date+n I…
Kyle
  • 53
  • 5
-2
votes
1 answer

Library unpacking MySQL BLOBS in c#

I have some BLOBS column in a MySQL database. I want to unpack, read it and the save unpacked data into another table. Is there a library for unpacking MySQL BLOBS in c#? I have tried using code but was wondering if there was any free library for…
Ritesh
  • 9
  • 5
-2
votes
1 answer

how to unpack these type of javascript files?

var n=this;eval((function(Q){for(var C in…
Vaibhav Gupta
  • 1,592
  • 1
  • 13
  • 23
-2
votes
1 answer

Python unpack like in PHP

In PHP I will do it like this: $res = unpack('C*', "string"); And $res variable will be an array of size 6: Array ( [1] => 115 [2] => 116 [3] => 114 [4] => 105 [5] => 110 [6] => 103 ) I want to do the same trick in Python. I tried this: >>> from…
Jacobian
  • 10,122
  • 29
  • 128
  • 221
-2
votes
1 answer

Python2.7: Too many Values to Unpack - Number of Columns unknown

I have a file that I want to unpack and utilise the columns in different files. The issue I have is that the file I want to unpack varies from row to row on the number of columns it has (for example row 1 could have 7 columns, row 2 could have…
user2320229
  • 71
  • 1
  • 7
-2
votes
1 answer

PHP unpack() analogue functions in Qt4

How to implement on Qt logic of PHP functions unpack?
Baltazor
  • 13
  • 4
-2
votes
3 answers

perl quick switch from quaternary to decimal

I'm representing nucleotides A,C,G,T as 0,1,2,3, and afterwards I need to translate the sequence representing as quaternary to decimal. Is there a way to achieve this in perl? I'm not sure if pack/unpack can do this or not.
lolibility
  • 2,187
  • 6
  • 25
  • 45
-3
votes
1 answer

Purpose of struct.unpack

I have been trying to figure this out for some time now and i get nowhere. I have two unsigned integers. This means four bytes. 3A BC 00 00 These represent a float value. I want to convert them to float using python. I can do this with python using…
user1584421
  • 3,499
  • 11
  • 46
  • 86
-3
votes
3 answers

How to print a string before using "*" to unpack list

Is it possible to print a string before using the * operator when unpacking a tuple: m = ['b', 'a', 'e'] print(*m, sep = ',') b, a, e I tried to print something before it: print("String: " + *m, sep = ",") My desired output would be: String: b,…
ter123
  • 21
  • 7
-4
votes
2 answers

ValueError: too many values to unpack (Python 2.7)

values = data.split("\x00") username, passwordHash, startRoom, originUrl, bs64encode = values if len(passwordHash)!= 0 and len(passwordHash)!= 64: passwordHash = "" if passwordHash != "": passwordHash =…
Ionuț
  • 55
  • 1
  • 1
  • 9
-4
votes
2 answers

Pack and unpack in Perl

I confused with pack and unpack while writing a Perl script. What is the difference between between pack and unpack in Perl (explain with a simple example)?
-5
votes
2 answers

How do I use Perl's unpack?

I have an JSON Body of an http post that has to be split into 80 character double quoted strings - but - whenever I use unpack to read the first 80 characters, the string pointer in the source string (which is not CR/LF delimited at the end of each…
1 2 3
40
41