Extract data from ASCII file

William Park spam-opengeometry at yahoo.ca
Mon Feb 23 06:11:06 CET 2004

Ren <rlpreston at sbec.com> wrote:
> Suppose I have a file containing several lines similar to this:
> :10000000E7280530AC00A530AD00AD0B0528AC0BE2
> The data I want to extract are 8 hexadecimal strings, the first of
> which is E728, like this:
> :10000000 E728 0530 AC00 A530 AD00 AD0B 0528 AC0B E2
> Also, the bytes in the string are reversed. The E728 needs to be 28E7,
> 0530 needs to be 3005 and so on.
> I can do this in C++ and Pascal, but it seems like Python may be more
> suited for the task.
> How is this accomplished using Python?

1. Use FIXEDWIDTH in Awk.

2. Use string slice in Python.

3. Use variable operation in (Bash) shell.

William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
Linux solution for data management and processing. 

More information about the Python-list mailing list