issue with struct.unpack

9bizy a.m.akingbulu-11 at student.lboro.ac.uk
Tue Aug 28 18:34:11 EDT 2012


This is what I have to reproduce the challenge I am having below:


import csv
import struct


data = []

for Node in csv.reader(file('s_data.xls')):
    data.append(list((file('s_data.xls'))))
    
    
    data = struct.unpack('!B4HH', data)
    print "s_data.csv: ", data

I tries so many format for the struct.unpack but I got this errors:

Traceback (most recent call last):
  
    data = struct.unpack('!B4HH', data)
struct.error: unpack requires a string argument of length 11

On Saturday, 25 August 2012 19:34:39 UTC+1, 9bizy  wrote:
> I am trying to unpack values from sensor data I am retrieving through a serial cable, but I get errors while using struct.unpack, how can I use struct.unpack to unload the data in a readable format?
> 
> 
> 
> I checked the python documentation for struct and I can seen to find any argument for this.
> 
> 
> 
> I have data = struct.unpack('char',data) but I still get errors



More information about the Python-list mailing list