| View previous topic :: View next topic |
| Author |
Message |
phab Voice
Joined: 22 Aug 2005 Posts: 12
|
Posted: Thu Sep 08, 2005 6:59 pm Post subject: Need help with comparing two files... |
|
|
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 |
|
| Back to top |
|
 |
De Kus Revered One

Joined: 15 Dec 2002 Posts: 1361 Location: Germany
|
Posted: Thu Sep 08, 2005 7:17 pm Post subject: |
|
|
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... |
|
| Back to top |
|
 |
phab Voice
Joined: 22 Aug 2005 Posts: 12
|
Posted: Fri Sep 09, 2005 2:35 am Post subject: |
|
|
Thank you. I'll give it a try!
For other suggestions: Thanks!  |
|
| Back to top |
|
 |
phab Voice
Joined: 22 Aug 2005 Posts: 12
|
Posted: Fri Sep 09, 2005 5:01 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Sep 09, 2005 5:17 am Post subject: |
|
|
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]) |
|
| Back to top |
|
 |
phab Voice
Joined: 22 Aug 2005 Posts: 12
|
Posted: Fri Sep 09, 2005 6:52 am Post subject: |
|
|
| Thanks you. That's it ,-) |
|
| Back to top |
|
 |
|