excel转化为csv

import pandas as pdimport codecspd.set_option('display.width', 1000)pd.set_option('colheader_justify', 'center')xd = pd.ExcelFile('table_2018.xlsx')df = xd.parse()pd.set_option('colheader_justify', 'center')#设置html文件格式html_string = '''<!DOCTYPE html>  <head>  <meta charset="UTF-8">  <title></title>  </head>  <link rel="stylesheet" type="text/css" href="df_style.css"/>  <body>    {table}  </body></html>.'''with open('table_2018.html', encoding='utf-8', mode='w') as f:    f.write(html_string.format(table=df.to_html()))

posted @ 2021-11-06 21:37  xjspyx  阅读(16)  评论(0编辑  收藏  举报