I am taking in a file which is encoded with one of two codecs:
try:
decoded_file = open(fname, encoding ="ISO-8859-1")
except:
decoded_file = open(fname, encoding ="utf-8")
What I am hoping to achieve is that if I get a UnicodeEncodeError I can switch to the appropriate codec
writer = csv.writer(decoded_file) Throws UnicodeEncodeError on utf-8 but not iso-8859-1