This repository has been archived on 2025-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
Karaoke-Kingpin/filter_rows.py

17 lines
482 B
Python
Raw Normal View History

2025-03-19 10:04:16 +08:00
import pandas as pd
# 讀取Excel文件
input_file = 'SongsExport.xlsx' # 替換為你的文件名
output_file = 'SongsExport.xlsx' # 替換為你希望保存的文件名
# 使用pandas讀取Excel文件
df = pd.read_excel(input_file)
# 保留第一行和最後三行
rows_to_keep = pd.concat([df.head(1), df.tail(3)], ignore_index=True)
# 將結果保存到新的Excel文件
rows_to_keep.to_excel(output_file, index=False)
print(f"處理完畢,已保存到 {output_file}")