Steve Holden wrote:
> Dan Sommers wrote:
> > On 27 Sep 2005 19:01:38 -0700,
> > [EMAIL PROTECTED] wrote:
> >
> >
> >>with the binary stuff out of the way, what i have is this string data:
> >
> >
> >>20050922 # date line
> >>mike
> >>mike's message...
> >>20040825 # date line
> >>jeremy
> >>jeremy
Dan Sommers wrote:
> On 27 Sep 2005 19:01:38 -0700,
> [EMAIL PROTECTED] wrote:
>
>
>>with the binary stuff out of the way, what i have is this string data:
>
>
>>20050922 # date line
>>mike
>>mike's message...
>>20040825 # date line
>>jeremy
>>jeremy's message...
>>...
>
>
>>what i want to do
On 27 Sep 2005 19:01:38 -0700,
[EMAIL PROTECTED] wrote:
> with the binary stuff out of the way, what i have is this string data:
> 20050922 # date line
> mike
> mike's message...
> 20040825 # date line
> jeremy
> jeremy's message...
> ...
> what i want to do is to use the date line as the first
Magnus Lycka wrote:
> Why? It seems you are trying to use a string as some kind of container,
> and Python has those in the box. Just use a list of tuples, rather than
> a list of strings. That will work fine for .sort(), and it's much more
> convenient to access your data. Using the typical tool
[EMAIL PROTECTED] wrote:
> I edited my code earlier and came up with stringing the groups
> (200501202010, sender, message_string) into one string delimited by
> '%%%'.
Why? It seems you are trying to use a string as some kind of container,
and Python has those in the box. Just use a list of tuple
Thank you very much.
I'll look into this immediately.
I edited my code earlier and came up with stringing the groups
(200501202010, sender, message_string) into one string delimited by
'%%%'.
I could then sort the messages with the date string at the beginning as
the one being sorted with the b
On 17 Sep 2005 06:41:08 -0700, [EMAIL PROTECTED] wrote:
>Hello guys,
>
>I made a script that extracts strings from a binary file. It works.
>
>My next problem is sorting those strings.
>
>Output is like:
>
> snip
>200501221530
>John
>*** long string here ***
>
>200504151625
>Clyde
>*** cl
Uhm, if the file is clean you can use something like this:
data = """\
200501221530
John
*** long string here ***
200504151625
Clyde
*** clyde's long string here ***
200503130935
Jeremy
*** jeremy string here """
records = [rec.split("\n") for rec in data.split("\n\n")]
records.sort()
print
Hello guys,
I made a script that extracts strings from a binary file. It works.
My next problem is sorting those strings.
Output is like:
snip
200501221530
John
*** long string here ***
200504151625
Clyde
*** clyde's long string here ***
200503130935
Jeremy
*** jeremy string here **