Specifying an encoding for our CSV file

Our application is currently saving CSV files using system default encoding. This could be a problem for Windows and macOS users if they try to use unicode characters.

In models.py, we need to locate the three instances of open() in our CSVModel class and add an encoding, as follows:

with open(self.filename, 'w', encoding='utf-8') as fh:
                ...

With this change, the unicode characters should no longer be a problem.

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.