joeyagreco / leeger

Instant stats for any fantasy football league.
https://pypi.org/project/leeger
MIT License
61 stars 17 forks source link

Excel Color Map Raising Error #115

Closed bschleter closed 11 months ago

bschleter commented 11 months ago

League Loader

Yahoo

Summary

Believe yahoo bug?

Traceback (most recent call last): File "/Users/brandonschleter/Sleeper/my_script.py", line 41, in leagueToExcel(myLeague, "/myLeagueStats.xlsx") File "/Users/brandonschleter/miniconda3/envs/Sleeper/lib/python3.10/site-packages/leeger/util/excel.py", line 68, in leagueToExcel teamIdToColorMap[team.id] = ownerIdToColorMap[team.ownerId] KeyError: '959818########'`

Here was CoPilot's suggestions for excel.py (unsure if needed)

`if team.ownerId not in ownerIdToColorMap: ownerIdToColorMap[team.ownerId] = default_color # replace default_color with the default color value you want to use

teamIdToColorMap[team.id] = ownerIdToColorMap[team.ownerId]`

Thoughts?

League Info

I am doing this by combining a Yahoo loader (successful API links) and a Sleeper loader. macos. I do not believe it is even getting to the point of the Sleeper loader due to color key error with yahoo. Our league changes it's 'name' each year, keeps things fresh.

using file name as my_script.py to keep all things congruent.

Error Logs

No response

bschleter commented 11 months ago

in addition- Sleeper was able to download perfectly when i commented out the combined loader code that had Yahoo in it.

joeyagreco commented 11 months ago

I think this issue is stemming from the owner names between Sleeper and Yahoo Leagues not merging correctly.

Can you try adding something like this to your script to tell it what owner names go with each other so it can merge the leagues correctly?

bschleter commented 11 months ago

had same thought and almost certain that's the issue too. Once able to check owner names in yahoo, I'll get on it.

joeyagreco commented 11 months ago

Sounds good! You could always load the yahoo league and then just print out all the owner names if that's faster.

DevAndADream commented 11 months ago

I seem to be running into the same issue. I noticed this happens when I add leagues together that have a different amount of teams between seasons.

I tried loading a ESPN league that had 8 teams the first year, and 12 teams the second year, and I was presented with a "owner was not previously loaded" error (the error being the owner that was not in the first season).

I then made both years separate and combined them using the + operator and then attempted to load into excel where I ran into this error.

bschleter commented 11 months ago

I think another issue is because when we all went to Sleeper, we all did owner names completely different than our real names.

As a joke I did my name like a Twitter bot....so its a word and mix of numbers and letters....

joeyagreco commented 11 months ago

@DevAndADream Leagues that do not have the same amount of teams cannot be combined currently. Perhaps I can look into a way to load them into the same sheet in the future, but for now I would just load them separately and load the stats into 2 different Excel sheets.

DevAndADream commented 11 months ago

I figured as much. I have went ahead and loaded them into separate sheets for each year and it works great. Thank you!