diff --git a/scoresheet.py b/scoresheet.py index 89b8bfa..60b47b2 100755 --- a/scoresheet.py +++ b/scoresheet.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # PYTHON_ARGCOMPLETE_OK ''' Reads text file with rows formatted as: @@ -20,6 +20,7 @@ import PyPDF2 import appy.pod.renderer import argcomplete +import charset_normalizer SEP = ';' @@ -68,8 +69,9 @@ def read_file(filename): :param filename: path to the file :returns: List of players """ - # read file - with open(filename) as input_file: + # Read CSV file + encoding = charset_normalizer.from_path(filename).best().encoding + with open(filename, encoding=encoding) as input_file: reader = csv.reader(input_file, delimiter=';', quotechar='"') players = list(reader) diff --git a/setup.py b/setup.py index 727b6d1..f362032 100644 --- a/setup.py +++ b/setup.py @@ -9,5 +9,5 @@ entry_points={ "console_scripts": ["scoresheet=scoresheet:main"] }, - install_requires=['PyPDF2', 'appy', 'argcomplete'] + install_requires=['PyPDF2', 'appy', 'argcomplete', 'charset-normalizer'] )