import pandas as pd
class Example:
def __init__(self, file_path):
self.in_file = file_path
def process_file(self):
# 读取Excel文件
raw_data = pd.read_excel(self.in_file)
# 检查DataFrame是否为空
if not raw_data.empty:
# 逐行迭代DataFrame
for _, row in raw_data.iterrows():
print(f"Name: {row['Name']}, Age: {row['Age']}, City: {row['City']}")
# 使用示例
example = Example('test.xlsx')
example.process_file()
pandas写入数据到EXCEL表格
于 2025-01-06 19:40:40 首次发布