我有一个Java应用程序,它读取已在Excel中创建的CSV文件(例如2007).有谁知道MS Excel使用什么字符集来保存这些文件?
我猜对了:
但我无法使用这些字符集类型解码扩展字符(例如法语强调字母).
I have trouble reading the csv file by python. My csv file has Korean and numbers.
Below is my python code.
import csv
import codecs
csvreader = csv.reader(codecs.open('1.csv', 'rU', 'utf-16'))
for row in csvreader:
print(row)
Run Code Online (Sandbox Code Playgroud)
First, there was a UnicodeDecodeError when I enter "for row in csvreader" line in the above code.
So I used the code below then the problem seemed to be solved
csvreader = csv.reader(codecs.open('1.csv', 'rU', 'utf-16'))
Run Code Online (Sandbox Code Playgroud)
Then I ran into NULL byte error. Then I can't …
即使我提到过,我也在使用 Python3 读取文本文件,encoding但它重新运行:
UnicodeDecodeError:'utf-8' 编解码器无法解码位置 96 中的字节 0x92:无效起始字节 [05/May/2018 03:35:45]“POST /app/HTTP/1.1”500 14383
它不是重复的,但它特定于byte 0x92.
这是我尝试过的:
txt = Path(text_path).read_text(encoding="utf-8")
Run Code Online (Sandbox Code Playgroud)