에 ASCII에서 파일이 내가 노력 코드입니다 :인코딩 UTF8
import codecs
import chardet
BLOCKSIZE = 9048576 # or some other, desired size in bytes
with codecs.open("MFile2016-05-22.csv", "r", "ascii") as sourceFile:
with codecs.open("tmp.csv", "w", "utf-8") as targetFile:
while True:
contents = sourceFile.read(BLOCKSIZE)
if not contents:
break
targetFile.write(contents)
file = open("tmp.csv", "r")
try:
content = file.read()
finally:
file.close()
encoding = chardet.detect(content)['encoding']
print encoding
을 테스트 한 후, 나는 여전히에서 "ASCII"를 얻을 encode의 값 인코딩이 변경되지 않았습니다. 내가 뭘 놓치고 있니?
-8 파일. 사실, 거의 모든 인코딩 (ASCII 기반)에서 유효합니다. – deceze