Unix fold command in python
kav062 at yahoo.com
Mon Jun 14 17:27:41 CEST 2004
diabolik at uku.co.uk (dean) wrote in message news:<70efe2ee.0406140252.2c7b0989 at posting.google.com>...
> Hello Group:
> Hopefully someone can answer my question.
> I have a unix shell command that I would like to emulate in python.
> The command is FOLD. I am scanning a file that contains a stream of
> data with a record size of 242 bytes but no record delimiters. There
> are multiple fields in each record that can be mapped according to
> their position:
> field1 byte 0-4
> field2 byte 5-8
> fieldn byte 238-242
> How do I make python read a record in and report the contents of a
> particular field (and may be carry out an operations with that field).
> Much appreciated
Is the data in some packed binary format? It seems from your
description that this is the case. I would consider looking at the
struct module. Read the docs on it to find out specifics of usage.
More information about the Python-list