Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28039

Re: issue with struct.unpack

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'binary': 0.05; 'subject:skip:s 10': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'aug': 0.13; "skip:' 30": 0.15; 'data)': 0.16; 'interprets': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:issue': 0.16; '>>>': 0.18; 'import': 0.21; 'struct': 0.22; 'example': 0.23; 'external': 0.24; 'raw': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'character.': 0.29; 'source': 0.29; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'excel': 0.33; 'received:org': 0.36; 'explain': 0.36; 'but': 0.36; 'subject:with': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'where': 0.40; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'provide': 0.62; 'series': 0.63; '138,': 0.84; 'dennis': 0.91; 'received:108': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: issue with struct.unpack
Date Tue, 28 Aug 2012 22:40:04 -0400
Organization > Bestiaria Support Staff <
References <2cc8b390-0b7a-4a0f-ac88-113daf65eba5@googlegroups.com> <mailman.3811.1345922216.4697.python-list@python.org> <f8a1ab56-5387-4e3f-b3ef-2f047973f857@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-79-222-169.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3916.1346208014.4697.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346208014 news.xs4all.nl 6935 [2001:888:2000:d::a6]:47932
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28039

Show key headers only | View raw


On Tue, 28 Aug 2012 15:35:58 -0700 (PDT), 9bizy
<a.m.akingbulu-11@student.lboro.ac.uk> declaimed the following in
gmane.comp.python.general:

> 
> I used this documents but they do not explain or provide an example on how to use struct.unpack for sensor data from an external source or even data from a excel sheet.

	Why should it?... struct doesn't care WHERE the data came from; it
just takes a /string of bytes/ and interprets the contents as a series
of raw binary fields based upon the format character.

>>> import struct
>>> data = "elevenbytes"
>>> struct.unpack("!B4HH", data)
(101, 27749, 30309, 28258, 31092, 25971)
>>> ndata = [30, 138, 32260, 563, 3238, 23537]
>>> struct.pack("!B4HH", *ndata)
'\x1e\x00\x8a~\x04\x023\x0c\xa6[\xf1'
>>> 
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-25 11:34 -0700
  Re: issue with struct.unpack Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-25 20:12 +0100
  Re: issue with struct.unpack MRAB <python@mrabarnett.plus.com> - 2012-08-25 20:16 +0100
    Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 15:35 -0700
      Re: issue with struct.unpack MRAB <python@mrabarnett.plus.com> - 2012-08-28 23:53 +0100
      Re: issue with struct.unpack Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-28 22:40 -0400
    Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 15:35 -0700
  Re: issue with struct.unpack Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-25 19:31 -0400
    Re: issue with struct.unpack Alexander Blinne <news@blinne.net> - 2012-08-26 14:53 +0200
  Re: issue with struct.unpack MRAB <python@mrabarnett.plus.com> - 2012-08-28 23:49 +0100
    Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 16:01 -0700
    Re: issue with struct.unpack MRAB <python@mrabarnett.plus.com> - 2012-08-29 00:36 +0100
      Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 16:55 -0700
      Re: issue with struct.unpack 9bizy <a.m.akingbulu-11@student.lboro.ac.uk> - 2012-08-28 16:55 -0700
  Re: issue with struct.unpack Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-28 22:31 -0400

csiph-web