へのファイル:それをテストした後エンコード私はUTF8エンコードにASCIIからcsvファイルをエンコードしたい、これは私が試したコードである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」を取得エンコーディングの値エンコーディングは変更されませんでした。私は何が欠けていますか?
任意のASCIIファイルがすでに有効なUTFです-8ファイル。実際、ほとんどすべてのエンコーディング(ASCIIベース)では有効です。 – deceze