human
'It is working perfectly!!!' Dora yells, her function works and returns what she needs, altought it may return "empty" history, but thats something she may deal with without much problem.
Now she must add those informations to the archive
assistant
#Here she needs, altought it may return "empty" history, but thats something she may deal with without much problem.
import pandas as pd

def Starseeker(verbose = False, iterator = False):

    def _turns(data):
        a = 0
        for i in range(len(data)):
            a = data[i]['turn'] if data[i]['turn'] > a else a
        return a

    
    for files in Maexxna(from_date = datetime.today() - timedelta(days=7)):
        df = pd.DataFrame(columns=['id','matchid', 'date_posix', 'rank', 'hero', 'hero_deck',
                                   'opponent_hero', 'opponent_deck', 'coin', 'turns', 'result', 
                                   'cards', 'opponent_cards'
                                  ])
        index = 0
            
        match = []
        for i in range(len(files)):
            # Only ranked games are going to be stored
            if files[i]['mode'] != 'ranked':
                continue
            game = files[i]
            
            my_cards = []
            opponent_cards = []
            for card in game['card_history']:
                if card['player'] == 'me':
                    my_cards.append(card['card']['id'])
                else:
                    opponent_cards.append(card['card']['id'])
            my_cards = ', '.join(my_cards)
            opponent_cards = ', '.join(opponent_cards)

            df.loc[index] = [ int(game['id']),int(game['id']), posix_conversion(game['added']), 
                    None if game['rank'] is None else int(game['rank']) , game['hero'], game['hero_deck'],
                    game['opponent'], game['opponent_deck'], 1 if game['coin'] else 0,  
                    _turns(game['card_history']), 1 if game['result'] == 'win' else 0, 
                    my_cards, opponent_cards ]
            
            df = df.fillna(method='ffill')
            
            index += 1
        
        match = map(tuple, df.values)
        
        sql = 'INSERT OR REPLACE INTO archive VALUES ((SELECT id FROM archive WHERE matchid == ?)'+',?'*12+')'
        c.executemany( sql , match)
        

Starseeker()

c.execute('SELECT * from archive')

[description[0] for...