I ran few commands like recode
and iconv but none worked. I think doing this task via Python will surely help.
What should be the appropriate approach?
I ran few commands like recode
and iconv but none worked. I think doing this task via Python will surely help.
What should be the appropriate approach?
import codecs
import shutil
with codecs.open("inputfile.csv", encoding="utf-16") as input_file:
with codecs.open(
"outputfile.csv", "w", encoding="utf-8") as output_file:
shutil.copyfileobj(input_file, output_file)
NB: make sure to read the file with the correct encoding in this case utf-16 as specified in the question and then write it to an output file using the utf-8 encoding sequence.
import codecs
import shutil
with codecs.open("input_file.utf8.csv", encoding="utf-8") as input_file:
with codecs.open(
"output_file.utf16.csv", "w", encoding="utf-16") as output_file:
shutil.copyfileobj(input_file, output_file)