ai_member_xiaoyan/read_excel.py

16 lines
445 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pandas as pd
# 读取Excel文件
excel_file = pd.ExcelFile('./22163_data.xlsx')
# 获取所有sheet名称
print("所有sheet名称", excel_file.sheet_names)
print("\n" + "="*50 + "\n")
# 遍历每个sheet输出内容
for sheet_name in excel_file.sheet_names:
print(f"Sheet{sheet_name}")
df = pd.read_excel(excel_file, sheet_name=sheet_name)
print(df.to_csv(sep='\t', na_rep='nan'))
print("\n" + "="*50 + "\n")