I am using the Python CSV library to read two CSV files.
One is encoded with UTF-8-BOM, another is encoded with UTF-8. In my practice, I found that both files could be read by using "utf-8-sig" as encoding type:
from csv import reader
with open(file_path, encoding='utf-8-sig') as csv_file:
c_reader = reader(csv_file, delimiter=',')
headers = next(c_reader)
for row in c_reader:
print(row)
I want to confirm, is "utf-8-sig" suitable for decoding both UTF-8 and UTF-8 BOM? I am using Python version 3.6 and 3.7. Thanks for your answers!