Last time I looked at the contents of the data one by one, so this time I would like to extract only the data I want from it. (Click here for the previous article https://qiita.com/mattya_527/items/d9861db5e129d92c1637)
As of February 1, 2020 OS:windows10 Anaconda:4.8.1 python:3.7.6
The data I want this time is the number of wins and losses, the number of kills, the number of deaths, the number of assists, the kill involvement rate, the champion used, the champion who played, the lane, CS, the gold earned, the damage done to the champion, the time of the game To go. Game mode is narrowed down to rank.
Looking at what I checked last time,
item | Object name | Mold |
---|---|---|
Win or lose | win | bool |
Number of kills | kills | int |
Number of deaths | deaths | int |
Number of assists | assists | int |
champion | championId | int |
lane | lane, role | str |
CS | totalMinionsKilled | int |
Earn gold | goldEarned | int |
Damage to the champion | magicDamageDealtToChampions,physicalDamageDealtToChampions,total of trueDamageDealtToChampions | int |
Game time | gameDuration | int |
Whether it is a ranked game | queueId=420 | int |
First, give out the names of everyone to limit the players to yourself.
for i in range(10):
match_data["participantIdentities"][i]["player"]
print(match_data["participantIdentities"][i]["player"]["summonerName"])
(For the time being, the SN of other people is hidden.)
You can see that if you want to limit yourself only, you can judge whether it matches the one defined by name last time.
for i in range(10):
if match_data["participantIdentities"][i]["player"]["summonerName"] == name: #Does the summoner name match?
par_Id = match_data["participants"][i]["participantId"]
print(par_Id) #Output participantId
#par_Output the data that matches Id
if match_data["participants"][par_Id-1]["stats"]["participantId"] == par_Id: #par_Id-1 matches the index
print(match_data["participants"][par_Id-1]["stats"]["win"]) #Win or lose
print(match_data["participants"][par_Id-1]["stats"]["kills"]) #Number of kills
print(match_data["participants"][par_Id-1]["stats"]["deaths"]) #Number of deaths
print(match_data["participants"][par_Id-1]["stats"]["assists"]) #Number of assists
print(match_data["participants"][par_Id-1]["championId"]) #Champion used
print(match_data["participants"][par_Id-1]["timeline"]["lane"]) #lane
print(match_data["participants"][par_Id-1]["timeline"]["role"]) #roll
print(match_data["participants"][par_Id-1]["stats"]["totalMinionsKilled"]) #CS **Is there anything other than minions and jungle creep that is necessary for CS because it is not enough for CS seen in OPGG?
print(match_data["participants"][par_Id-1]["stats"]["goldEarned"]) #Earn gold
print(match_data["participants"][par_Id-1]["stats"]["magicDamageDealtToChampions"] + match_data["participants"][par_Id-1]["stats"]["physicalDamageDealtToChampions"] + match_data["participants"][par_Id-1]["stats"]["trueDamageDealtToChampions"]) #Damage to the champion
print(match_data["participants"][par_Id-1]["teamId"]) #100 is the blue side, 200 is the red side
print(match_data["gameDuration"]) #Game time(Seconds)
I want to narrow down to ranked games, so I will make that judgment. Rank has queueId 420, so
if match_data["queueId"] == 420:
This can be identified. The reason why I want to narrow down to rank is that unless it is a rank game, rolls and lanes will be NONE and I can not collect the desired data.
This time, I was able to get the information I wanted by picking up the data for my one game. Next, I would like to upload this data to the database. That's why I will study the database and start again.
Recommended Posts