from pathlib import Path


def gamelocation(data, tmp_path_factory):
    """Write data to a temporary directory."""
    location = tmp_path_factory.mktemp("data")
    Path(location, "2018-19", "model-data").mkdir(parents=True)
    for name, game in data.groupby("GAME_ID"):
        game.to_csv(Path(location, "2018-19", "model-data", f"data_{name}.csv"), sep="|")
    
    return str(location)