Extract data from ASCII file

wes weston wweston at att.net
Sun Feb 22 21:12:38 EST 2004


Ren,
    If you go here:

http://www.python.org/doc/current/tut/node5.html#SECTION005120000000000000000

about half way down the page it talks about string slicing.

wes

Ren 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?




More information about the Python-list mailing list