Draw in 10h30, hurry up to join the list!By the way, here I show you the method I will use to randomly draw players. I made it last night. In
Python 3.
I simply use random.choice(list) from
random native module.
http://pastebin.com/Randomly Draw Players.py# -*- coding: utf-8 -*-
# Python 3
# Randomly Draw Players
import sys
import pathlib
import random
if len(sys.argv) < 2:
raise Exception("Missing argument: input_file_name")
script_file_name = sys.argv[0]
input_file_path = pathlib.Path(sys.argv[1])
with open(file=str(input_file_path.absolute()),
mode='r',
buffering=-1,
encoding='utf-8'
) as input_file: # {
players_dict = dict()
input_file.lineno = 0
for input_line in input_file: # {
input_file.lineno += 1
try:
player_name, player_id = input_line.strip().split('\t')
except ValueError:
raise Exception("File error {!r} at line {}!".format( input_file_path.name, input_file.lineno ))
else:
players_dict.update({player_name: player_id})
# }
# } with open
if not len(players_dict):
raise Exception("Missing players")
output_file_path = input_file_path
i = 0
while output_file_path.exists(): # { Find an no-existing file name
i += 1
output_file_path = pathlib.Path( # Folder + name_base + name_extension
input_file_path.parent,
input_file_path.stem + " output {}".format(i) + input_file_path.suffix
)
# }
with open(file=str(output_file_path.absolute()),
mode='w',
buffering=-1,
encoding='utf-8'
) as output_file: # {
while len(players_dict): # { Extract randomly each players
player_chosen_name = random.choice(list(players_dict.keys())) # Choose randomly a player name
player_chosen_id = players_dict.pop(player_chosen_name) # Extract and remove from dictionary
output_file.writelines( "{}\t{}\n".format(player_chosen_name, player_chosen_id) )
# }
# } with open
With currently players list.txt:
ARN_ 9553
Algarn 21882
Apsod 2742
Arrowblood 2507
Austrian 15140
BadooN 20628
Bittersteel 23083
Chosen1 21496
Chris_the_Animal 16300
Dolphin 3134
Eddy 3794
Erzengel 14962
FRANK_THE_TANK 9575
FleetFox 18368
Halfdan_stenman 19789
Hearst_ 9626
Heibai 22371
IR_Kuoin 2879
Jacaroma 24857
Jona 8502
Kalp 9749
Kaoklai 7844
Keshian 433
Killer 23562
Konrax 1462
Krex 23841
Laufknoten 4659
Lysander 7724
Mallets 17141
Man of Steel 22646
Molly 190
Moncho 8751
Nashringa 17359
Nehvar 11660
Nordwolf 3833
PanPan 192
Panuru 6475
Patoson 7666
Penitent 5186
Radament 1077
Rhekimos 403
Richyy 19763
SIrCampALot 24887
Sharpe 23244
Spartacus 8762
Sparvico 20371
StonedSteel 22041
Strudog 9536
SugarHoe 23289
Tanken 6659
TheZeus 22604
Thorvic 19131
Thryn 23616
Tore 10865
Tuetensuppe 7845
UrukHai 5497
Viriathus 17666
Vrael 1652
WITCHCRAFT 6845
[ptx] 455
jergu 18837
karasu 3422
lombardsoup 16307
naduril 1479
njames89 16862
pepejul 674
sF_Guardian 1192
skeletzo 22940
vipere 19401
wayyyyyne 2144
zottlmarsch 6284
To use it, simply open the command line: python.exe "Randomly Draw Players.py" "players list.txt"
It will create a new file randomly sorted.