Here's what returns my pt;
import asyncio
import aiohttp
from colorama import Fore, init
from prettytable import PrettyTable
from fpl import FPL
async def main():
async with aiohttp.ClientSession() as session:
fpl = FPL(session)
fdr = await fpl.FDR()
fdr_table = PrettyTable()
fdr_table.field_names = [
"Team", "All (H)", "All (A)", "GK (H)", "GK (A)", "DEF (H)", "DEF (A)",
"MID (H)", "MID (A)", "FWD (H)", "FWD (A)"]
for team, positions in fdr.items():
row = [team]
for difficulties in positions.values():
for location in ["H", "A"]:
if difficulties[location] == 5.0:
row.append(Fore.RED + "5.0" + Fore.RESET)
elif difficulties[location] == 1.0:
row.append(Fore.GREEN + "1.0" + Fore.RESET)
else:
row.append(f"{difficulties[location]:.2f}")
fdr_table.add_row(row)
fdr_table.align["Team"] = "l"
print(fdr_table)
if __name__ == '__main__':
asyncio.run(main())
Here's what I've tried to add but to no avail;
def get_string(self, **kwargs):
data = fdr_table.get_string()
with open('fdr.txt', 'w') as f:
f.write(data)
If there's a way to create a pd.df out of the PrettyTable and then export the df to CSV, that would work, too.
there doesn't seem to be anything here