python学习(五)--- 处理Excel
2018-02-24 11:48
423 查看
#打开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的强大工具:openpyxl相关文章推荐
- python学习笔记(excel中处理日期格式)
- Python 学习笔记 -处理excel
- Python字符串处理(版本2.7)-学习笔记
- Python处理Excel数据
- Python 处理 Excel
- Python学习笔记-DNS处理模块dnspython
- python学习四(处理数据)
- Python学习笔记整理(十七)异常处理
- Data Analysis学习笔记 --- Python数据清洗对字符串处理
- 使用minidom来处理XML的示例(Python 学习)(转载)
- Python学习17:异常处理(一)
- 学习python的第四十七天-第九章 异常处理与程序调试
- Python学习18_高级形态学处理
- Python学习笔记-数据报表之Excel操作模块
- python excel 处理
- Python对CSV、Excel、txt、dat文件的处理
- Python学习笔记之错误处理(关键词:错误处理、异常机制、try、except、else、finally、raise)
- Python处理Excel数据
- [IT学习]Python如何处理异常特殊字符
- 关于Python操作excel过程中,将多个内容写到同一个excel的不同sheet页的处理