This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Need help with comparing two files...

Old posts that have not been replied to for several years.
Locked
p
phab
Voice
Posts: 12
Joined: Mon Aug 22, 2005 6:34 am

Need help with comparing two files...

Post by phab »

Hello guys.

I wrote something like a ranking (most active users).
I store them in a file which looks like:

01|phab
02|bot1
03|anotherone
04|nickname
05|sweety
...

I generate the stats each Sunday (for example). Now I want the bot to inform the channel with something like:

"Active Users v1.0: phab isn't place #1 anymore, nickname got him! phab is now on place 03. Sweety is more active than anotherone this week, too."

I hope you understand... I want to say which user is activer than the others and went up in my ranking.

Any ideas how I could handle this? At the moment I dont know... :-(

Please help!

Regards
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

split them into a list like
[split $rankA \n] and [split $rankB \n]
after that you can compare them like
[lindex [split [lindex $rankA 0] |] 1] == [lindex [split [lindex $rankB 0] |] 1]
dont know if there is a more elegant way, maybe using it within a foreach loop compresses the code a bit.
if you have a missmatch, you can use lsearch to find the old/new rank.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
p
phab
Voice
Posts: 12
Joined: Mon Aug 22, 2005 6:34 am

Post by phab »

Thank you. I'll give it a try! :-)

For other suggestions: Thanks! :)
p
phab
Voice
Posts: 12
Joined: Mon Aug 22, 2005 6:34 am

Post by phab »

I can't get it working :-(

I read the old-ranking file till it's eof.. but i dont know how to compare the right way :(

Any ideas?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

if your data is ordered by rank, there's no need of the first field

read the two files in 2 lists, then for each element of the first list compare its index to the same element's index in the second list (to find that index, use [lsearch])
p
phab
Voice
Posts: 12
Joined: Mon Aug 22, 2005 6:34 am

Post by phab »

Thanks you. That's it ,-)
Locked