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_columns.py

18 lines
506 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)
# 保留第一列和最後三列
columns_to_keep = [df.columns[0]] + df.columns[-3:].tolist()
df_filtered = df[columns_to_keep]
# 將結果保存到新的Excel文件
df_filtered.to_excel(output_file, index=False)
print(f"處理完畢,已保存到 {output_file}")