def guess_encoding(self, file_name):
csv_file = file_name
with io.open(csv_file, "rb") as f:
self.data = f.read(5)
if self.data.startswith(b"\xEF\xBB\xBF"): # UTF-8 with a "BOM"
return "utf-8-sig"
elif self.data.startswith(b"\xFF\xFE") or self.data.startswith(b"\xFE\xFF"):
return "utf-16"
else: # in Windows, guessing utf-8 doesn't work, so we have to try
try:
with io.open(csv_file, encoding="utf-8") as f: