create account

Exporting Rabona teams into EXCEL files by emrebeyler

View this thread on: hive.blogpeakd.comecency.com
· @emrebeyler · (edited)
$10.78
Exporting Rabona teams into EXCEL files
<center><img src="https://i.imgur.com/oVKm1G8.png"></center>
***

The team page on Rabona doesn't let you filter/sort players by their properties. I've needed that functionality to plan my next season's roaster, so I have decided to hack a quick script to get the data and export it to excel (`.xlsx` format)


```
import pandas as pd
from rabona_python import RabonaClient

PLAYER_TYPE_GOAL_KEEPER = "1"
PLAYER_TYPE_DEFENDER = "2"
PLAYER_TYPE_MIDFIELDER = "3"
PLAYER_TYPE_ATTACKER = "4"

PLAYER_TYPE_MAP = {
    PLAYER_TYPE_GOAL_KEEPER: "goal keeper",
    PLAYER_TYPE_DEFENDER: "defender",
    PLAYER_TYPE_MIDFIELDER: "midfielder",
    PLAYER_TYPE_ATTACKER: "attacker",
}


def get_players(username):
    # https://api.rabona.io/team?user=emrebeyler
    rabona_client = RabonaClient()
    players = rabona_client.team(user=username)
    return players


def normalize_players(players):
    normalized_players = []
    for player in players:
        # human readable type
        player["position"] = PLAYER_TYPE_MAP.get(player["type"])
        player["OS"] = player["overall_strength"]
        player["GK"] = player["goalkeeping"]
        player["TP"] = player["teamplayer"]
        # not needed
        del player["type"]
        del player["ask_id"]
        del player["teamplayer"]
        del player["goalkeeping"]

        normalized_players.append(player)

    return normalized_players


def main(username):
    players = normalize_players(get_players(username)["players"])

    df = pd.DataFrame(players, columns=[
        "uid",
        "name",
        "position",
        "age",
        "OS",
        "GK",
        "defending",
        "passing",
        "dribbling",
        "shot",
        "headball",
        "form",
        "speed",
        "cleverness",
        "TP",
        "endurance",
        "vulnerability",
        "no_yellow_cards",
        "salary",
        "games_blocked",
        "games_injured",
        "for_sale",
        "frozen",
    ])

    print(df)

    df.to_excel(f"players_{username}.xlsx", header=True)

main("emrebeyler")
```
***

Just update the first argument in the main function with your username and let the script run. A new file (`players_{username}` will be created on the script's directory.) You need Python3, pandas, and rabona_python libraries.

#### Result
---
<center><img src="https://i.imgur.com/pJxKuVU.png"></center>
--
I might transform this into a small web app so that you can download the same excel without knowing any scripting spells. Just let me know if that would be something useful for you.

Posted with [STEMGeeks](https://stemgeeks.net)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 245 others
properties (23)
authoremrebeyler
permlinkexporting-rabona-teams-to-excel-files
categoryhive-163521
json_metadata{"tags":["rabona","python","development","stem"],"image":["https://i.imgur.com/oVKm1G8.png"],"app":"stemgeeks/0.1","format":"markdown","canonical_url":"https://stemgeeks.net/@emrebeyler/exporting-rabona-teams-to-excel-files","links":["https://stemgeeks.net"]}
created2020-11-22 23:33:00
last_update2020-11-22 23:34:51
depth0
children12
last_payout2020-11-29 23:33:00
cashout_time1969-12-31 23:59:59
total_payout_value6.146 HBD
curator_payout_value4.634 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,609
author_reputation448,535,049,068,622
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,642,332
net_rshares54,137,152,096,098
author_curate_reward""
vote details (309)
@aeneas.fund ·
Aeneas is a blockchain project under development and a decentralized blogging platform based on Hive spesialized on the #social #politics #economics #indiejournalizm and all the #cryptocurrency related threads <br>Join <a href='http://aeneas.blog' target = '_blank'>Aeneas.Blog</a> to earn more ASH for your unique content! <br>Dear, @emrebeyler, you have received <code>ASH</code> tokens! <br> Join our <a href = 'http://bit.ly/aeneasdiscord'>Discord Server </a> for further updates! <br> <img src = 'http://i.imgur.com/xu8QTmA.png' width = '150px'><p font size = 'small'> </p> </center> 
properties (22)
authoraeneas.fund
permlinkre-exporting-rabona-teams-to-excel-files-20201123t065214z
categoryhive-163521
json_metadata"{"app": "beem/0.24.19"}"
created2020-11-23 06:52:15
last_update2020-11-23 06:52:15
depth1
children0
last_payout2020-11-30 06:52:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length589
author_reputation5,693,157,434,022
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,645,901
net_rshares0
@bashadow ·
$0.03
Seems like every time I turn around lately I keep think I am in deep water trying to learn a little python 3 programming. Another aspect to look into the panda stuff. I wonder where it will all end, still fun trying to get out of the driveway. One day I may make it to the street.
👍  , , ,
properties (23)
authorbashadow
permlinkre-emrebeyler-qk8bbj
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2020.11.1"}
created2020-11-23 03:06:54
last_update2020-11-23 03:06:54
depth1
children0
last_payout2020-11-30 03:06:54
cashout_time1969-12-31 23:59:59
total_payout_value0.012 HBD
curator_payout_value0.013 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length280
author_reputation100,388,692,638,882
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,644,339
net_rshares217,493,979,049
author_curate_reward""
vote details (4)
@beerlover ·
<div class='pull-right'>https://files.peakd.com/file/peakd-hive/beerlover/yiuU6bdf-beerlover20gives20BEER.gif<p><sup><a href='https://hive-engine.com/?p=market&t=BEER'>View or trade </a> <code>BEER</code>.</sup></p></div><center><br> <p> Hey @emrebeyler, here is a little bit of <code>BEER</code> from @stranger27 for you. Enjoy it!</p> <p>Learn how to <a href='https://peakd.com/beer/@beerlover/what-is-proof-of-stake-with-beer'>earn <b>FREE BEER</b> each day </a> by staking your <code>BEER</code>.</p> </center><div></div>
properties (22)
authorbeerlover
permlinkre-exporting-rabona-teams-to-excel-files-20201123t065218z
categoryhive-163521
json_metadata"{"app": "beem/0.23.11"}"
created2020-11-23 06:52:21
last_update2020-11-23 06:52:21
depth1
children0
last_payout2020-11-30 06:52:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length525
author_reputation25,787,219,315,076
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,645,904
net_rshares0
@manniman ·
properties (23)
authormanniman
permlinkre-emrebeyler-qk875r
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2020.11.1"}
created2020-11-23 01:37:03
last_update2020-11-23 01:37:03
depth1
children0
last_payout2020-11-30 01:37:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length11
author_reputation77,790,724,868,389
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,643,508
net_rshares417,077,464
author_curate_reward""
vote details (3)
@oliverschmid ·
Awesome! (:

> "I might transform this into a small web app so that you can download the same excel without knowing any scripting spells."

That would be pretty cool.
👍  , ,
properties (23)
authoroliverschmid
permlinkqk8hc5
categoryhive-163521
json_metadata{"app":"hiveblog/0.1"}
created2020-11-23 05:16:54
last_update2020-11-23 05:16:54
depth1
children1
last_payout2020-11-30 05:16:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length166
author_reputation108,456,372,075,578
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,645,321
net_rshares422,123,135
author_curate_reward""
vote details (3)
@emrebeyler ·
will build something very quick
properties (22)
authoremrebeyler
permlinkqk93l2
categoryhive-163521
json_metadata{"app":"hiveblog/0.1"}
created2020-11-23 13:17:27
last_update2020-11-23 13:17:27
depth2
children0
last_payout2020-11-30 13:17:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length31
author_reputation448,535,049,068,622
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,648,987
net_rshares0
@stranger27 ·
!ASH
!BEER
Great! Thank you!
👍  , , ,
properties (23)
authorstranger27
permlinkre-emrebeyler-qk8lqo
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2020.11.1"}
created2020-11-23 06:52:00
last_update2020-11-23 06:52:00
depth1
children2
last_payout2020-11-30 06:52:00
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length28
author_reputation49,275,349,388,874
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,645,898
net_rshares440,796,035
author_curate_reward""
vote details (4)
@aeneas.fund ·
Command accepted!
properties (22)
authoraeneas.fund
permlinkre-re-emrebeyler-qk8lqo-20201123t065220z
categoryhive-163521
json_metadata"{"app": "beem/0.24.19"}"
created2020-11-23 06:52:21
last_update2020-11-23 06:52:21
depth2
children0
last_payout2020-11-30 06:52:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length17
author_reputation5,693,157,434,022
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,645,902
net_rshares0
@emrebeyler ·
thanks
properties (22)
authoremrebeyler
permlinkqk8r66
categoryhive-163521
json_metadata{"app":"hiveblog/0.1"}
created2020-11-23 08:49:18
last_update2020-11-23 08:49:18
depth2
children0
last_payout2020-11-30 08:49:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length6
author_reputation448,535,049,068,622
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,646,742
net_rshares0
@uwelang ·
Nice one buddy and congrats to your win in the night - I only struggle with this:

>You need Python3, pandas, and rabona_python libraries.
👍  , ,
properties (23)
authoruwelang
permlinkqk8os4
categoryhive-163521
json_metadata{"app":"hiveblog/0.1"}
created2020-11-23 07:57:42
last_update2020-11-23 07:57:42
depth1
children2
last_payout2020-11-30 07:57:42
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length138
author_reputation826,992,595,589,956
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,646,386
net_rshares417,131,313
author_curate_reward""
vote details (3)
@emrebeyler ·
$0.03
will release a small web app to get the data, wait a little bit :)
👍  ,
properties (23)
authoremrebeyler
permlinkqk8r59
categoryhive-163521
json_metadata{"app":"hiveblog/0.1"}
created2020-11-23 08:48:45
last_update2020-11-23 08:48:45
depth2
children1
last_payout2020-11-30 08:48:45
cashout_time1969-12-31 23:59:59
total_payout_value0.014 HBD
curator_payout_value0.015 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length66
author_reputation448,535,049,068,622
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,646,739
net_rshares250,822,042,012
author_curate_reward""
vote details (2)
@uwelang ·
Great dude
properties (22)
authoruwelang
permlinkre-emrebeyler-qk8ttu
categoryhive-163521
json_metadata{"tags":["hive-163521"],"app":"peakd/2020.11.1"}
created2020-11-23 09:40:03
last_update2020-11-23 09:40:03
depth3
children0
last_payout2020-11-30 09:40:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length10
author_reputation826,992,595,589,956
root_title"Exporting Rabona teams into EXCEL files"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id100,647,169
net_rshares0