I am receiving the
TypeError: a bytes-like object is required, not str
but my str-object is bytes and have searched for an answer.
This is where the decoding happens without error:
for line in tmpFile:
sl = codecs.decode(bytes(line, encoding = 'utf-8'), encoding = 'utf-8').strip().split('\t')
writer.writerow(sl)
If I take out the (bytes(line,encofing = 'utf-8') part then I get the TypeError.
This is how I'm opening the file:
with open(output_path, mode = 'w') as out_file:
write_final_output(out_file, delimiter, tmpFile)
I've tried opening it with mode = 'w+' and with codecs and I still have the same problem which is that my csv file comes out encoded with the beginning reading like this:
b'101361\x01