[Tutor] Problem with logic while extracting data from binary file

Bryan Fodness bryan.fodness at gmail.com
Thu Mar 27 22:42:34 CET 2008


Thanks again,

I can't seem to keep track of my start values when I break up the value
variable into svalues.  Do you think I should do this, or should I have a
running count from the beginning of the file and keep track until the end?

I am trying to find \n0\x82\x00 and \n0\x84\x00 within the block.  I've
added the if statement, and it seems to enter the parseSequence function the
way I would expect, but it does not seem to populate the dictionary.

Sorry for so many questions about this, but I feel like I am so close.


    while next < len(data):
        for element, next, value, length in parseDataElement(data, next):
##            if element in ('\n0\x10\x00', '\n0@\x00', '\n0p\x00',
##                           '\n0\xb0\x00', '\n0\x80\x01'):
            if element == '\n0p\x00':
                start = 0
                while  start < length:
                    element, start, svalue = parseSequence(value, start)
                    if svalue.startswith('\xfe\xff\x00\xe0'):
                        start_2 = 0
                        element, start_2, svalue = parseSequence(svalue,
start)
                        search[element].append(svalue)
                    search[element].append(svalue)
            else:
                search[element].append(value)
    return search
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080327/d705feca/attachment.htm 


More information about the Tutor mailing list