Excel文件的读取和写入
2019-05-08 本文已影响0人
haokeed
# 必须先安装库
# pip install xlwt
# pip install xlrd
# 读取excel文件的第一种方法
xls_data=pd.read_excel('./data/driver.xlsx',index_col='uuid')
xls_data.head()
# 读取excel文件的第二种方法
# openyxl
# 必须安装 pip install openpyxl
import openpyxl
xls_file=pd.ExcelFile('./data/driver.xlsx')
xls_data=xls_file.parse('Sheet1',index_col='uuid') # 第一个参数表示对于的表名称
xls_data.head()
# 导出到excel
# pip install xlwt
xls_data.to_excel('./data/output/driver.xlsx')

