topic description
I want to merge csv files, but I"ve been writing because of coding. How do you want to solve the problem?
related codes
import os,codecs
cwd=os.getcwd()
fout=codecs.open("output.csv","w",encoding="utf-8-sig")
for file in os.listdir(cwd+"/air"):
fin=codecs.open("air/"+file,encoding="utf-8-sig")
for i in fin:
fout.write(i)
result
Traceback (most recent call last):
File "C:UsersVivisourcereposPythonApplication89PythonApplication89PythonApplication89.py", line 16, in < module >
for i in fin:
File "C:Program Files (x86) Microsoft Visual StudioSharedPython36_64libcodecs.py", line 713, in next
return next(self.reader)
File "C:Program Files (x86) Microsoft Visual StudioSharedPython36_64libcodecs.py", line 644, in next
line = self.readline()
File "C:Program Files (x86) Microsoft Visual StudioSharedPython36_64libcodecs.py", line 557, in readline
)data = self.read(readsize, firstline=True)
File "C:Program Files (x86) Microsoft Visual StudioSharedPython36_64libcodecs.py", line 503, in read
)newchars, decodedbytes = self.decode(data, self.errors)
File "C:Program Files (x86) Microsoft Visual StudioSharedPython36_64libencodingsutf_8_sig.py", line 117, in decode
)return codecs.utf_8_decode(input, errors)
UnicodeDecodeError: "utf-8" codec can"t decode byte 0xa4 in position 0: invalid start byte
Press any key to continue. . .