derek-adair / nflgame

A working snapshot of nflgame (for historic purposes). This project is no longer active.
http://nflgame.derekadair.com
The Unlicense
332 stars 100 forks source link

Seq.py is using Python 2 Version to Write Row to CSV #107

Closed jbarber3388 closed 4 years ago

jbarber3388 commented 4 years ago

In the current Seq.py file on line 333, the code to write row is like below:

csv.DictWriter(open(fileName, 'wb+'), fieldNames).writerows(rows)

However, that results in the following error:

File "C:\Users\jpb71\ENV\testNfl.py", line 10, in players.csv('rusing.csv') File "C:\Users\jpb71\ENV\lib\site-packages\nflgame\seq.py", line 333, in csv csv.DictWriter(open(fileName, 'wb+'), fieldNames).writerows(rows) File "c:\users\jpb71\appdata\local\programs\python\python38\Lib\csv.py", line 157, in writerows return self.writer.writerows(map(self._dict_to_list, rowdicts)) TypeError: a bytes-like object is required, not 'str'

This is happening because that is the python 2 version of that call. See: https://stackoverflow.com/questions/34283178/typeerror-a-bytes-like-object-is-required-not-str-in-python-and-csv

It should be:

'csv.DictWriter(open(fileName, 'w'), fieldNames).writerows(rows)'

derek-adair commented 4 years ago

I can throw this in or do you wanna submit a PR?

I will be ACTUALLY testing and releasing 2.0 in the next week or so.