Python学习记录
记录Python的各种
yaml 转 excel
import os
import yaml
import xlwt
ymls = os.listdir('./')
workbook = xlwt.Workbook(encoding='utf-8')
for q in ymls:
if 'yml' not in q:
continue
with open(q, encoding='utf-8') as f:
d = yaml.load(f)
sheet = workbook.add_sheet(d['categories'][0])
for i, pair in enumerate(d['conversations']):
sheet.write(i, pair)
workbook.save('converted.xls')