我试图加载一个现有的工作表和导入的文本文件(逗号分隔值)如下所示屏幕截图“‘UTF8’编解码器不能在0位置解码字节0xd0”,Python的投掷的错误
Excel工作表:
文本文件:
我使用的代码所示贝罗女:
# importing necessary modules for performing the required operation
import glob
import csv
from openpyxl import load_workbook
import xlwt
#read the text file(s) using the CSV modules and read the dilimiters and quoutechar
for filename in glob.glob("E:\Scripting_Test\Phase1\*.txt"):
spamReader = csv.reader((open(filename, 'rb')), delimiter=',')
#read the excel file and using xlwt modules and set the active sheet
wb = load_workbook(filename=r"E:\Scripting_Test\SeqTem\Seq0001.xls")
ws = wb.worksheets(0)
#write the data that is in text file to excel file
for rowx, row in enumerate(spamReader):
for colx, value in enumerate(row):
ws.write(rowx, colx, value)
wb.save()
我得到一个以下错误消息:
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd0 in position 0: invalid continuation byte
一个问题:你怎么知道蟒蛇导入从A3列在Excel工作表开始的文本数据?
谢谢你,亚当!我试图做到这一点,但仍然是同样的错误。 – Raj