python读取excel或csv文件时老是报错,一般需要进行什么样的优化
3个回答
展开全部
去掉第一行就不会报错了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import xlrd
EXCEL_BOOK_FULLNAME='FULL FILE NAME'
workbook=xlrd.open_workbook(EXCEL_BOOK_FULLNAME)
worksheet=workbook.sheet_by_name('Sheet1')
rows=worksheet.nrows #worksheet rows
cols=worksheet.ncols #worksheet columns
lists=[[],[],[],[]] #modify this according your column counts
for c in range(cols): #transfer excel values into lists
for r in range(rows):
lists[c].append(worksheet.cell_value(r,c))
EXCEL_BOOK_FULLNAME='FULL FILE NAME'
workbook=xlrd.open_workbook(EXCEL_BOOK_FULLNAME)
worksheet=workbook.sheet_by_name('Sheet1')
rows=worksheet.nrows #worksheet rows
cols=worksheet.ncols #worksheet columns
lists=[[],[],[],[]] #modify this according your column counts
for c in range(cols): #transfer excel values into lists
for r in range(rows):
lists[c].append(worksheet.cell_value(r,c))
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询