Reading binary data

Grant Edwards grante at visi.com
Wed Nov 23 13:20:48 EST 2005


On 2005-11-23, David M <Neruocomp at yahoo.com> wrote:
> OK so here is my task.  I want to get at the data stored in
> /var/account/pacct, which stores process accounting data, so that I can
> make it into a more human understandable format then what the program
> sa can do.  The thing is, its in a binary format and an example program
> that reads some data from the file is done in C using a struct defined
> in sys/acct.h.
>
> http://www.linuxjournal.com/articles/lj/0104/6144/6144l2.html
>
> So I was wondering how can I do the same thing, but in python?  I'm
> still learning so please be gentle.

use the struct module

http://www.python.org/doc/current/lib/module-struct.html

-- 
Grant Edwards                   grante             Yow!  O.K.! Speak with a
                                  at               PHILADELPHIA ACCENT!! Send
                               visi.com            out for CHINESE FOOD!! Hop
                                                   a JET!



More information about the Python-list mailing list