hi im using data from an API that comes out in this format ( spans large amounts of lines example given just shows 2 )
['347759', '98', '50752599']
['426291', '84', '3092962']
each line represents a different skill in a game, and each piece of data in the line represents the players rank in that skill, their level in that skill, and their total XP in that skill for example if the first skill is mining and the second skill is smithing the formatted data would be
Mining : rank=347759 , level = 98 , xp = 50752599
Smithing : rank=426291, level = 84, xp = 3092962
im using http requests to fetch this data and it spans many lines, currently im using this code ( see below ) to seperate out the data into the seperate integers on each line
line_count = 0
for line in data_processed:
if line != '':
skill_data = line.split(',')
player.mining.rank = skill_data[0]
player.mining.level = skill_data[1]
player.mining.xp = skill_data[2]
line_count = line_count + 1
obviously the issue with this is that when it moves onto the next line in the file ( the second trio of ints ) instead of player.mining.rank = skill_data[0]
etc i will instead need player.smithing.rank = skill_data[0]
and so on for 24 different lines (as there are 24 different skills in the game).
how would i dynamically switch from appending one class object such as 'mining' (Derived from 'Skills' class and declared under a 'Player' object) to another class object such as 'smithing'
any suggestions welcome - Comment if you need more explanation or context - i will reply quickly
i know i could use this (see below) but the problem is that i have multiple players calling from multiple http requests so it would span hundreds and hundreds of lines of code all very similar with just object names being different
if line_count == 1: player.mining.rank = skill_data[0]
and if line_count == 2: player.smithing.rank = skill_data[0]
for each player the object is their character name for example Conial = Player(...)