#打开excel文件返回目标sheet
def OpenExcelFile():
wb = load_workbook(excel_file_path_)
#print(wb.sheetnames)
sheet = wb.get_sheet_by_name('Sheet1')
#print(sheet['C'][0].value)
print('max col is %d' % sheet.max_column)
print('max row is %d' % sheet.max_row)
return sheet
#将excel文件中所有视频时间信息转化为dict,用于后续查询
def GetVideosTimeInfo():
sheet = OpenExcelFile()
video_dict = defaultdict(list)
for i in range(1,sheet.max_row):
index = sheet[str(i+1)][0].value
for j in range(1,sheet.max_column):
seconds = TimeFormatToSeconds(str(sheet[str(i+1)][j].value))
video_dict[index].append(seconds)
#print(video_dict)
return video_dict
python学习(五)--- 处理Excel
最新推荐文章于 2024-09-07 14:01:02 发布