INNER CODE UNIT · Python
add_column_to_excel
changyeyu/LLM-RL-Visualized · src/rename_images.py:6
def add_column_to_excel():
"""
Function 1: Add a third column to Excel files.
For each Excel file ("src/conf/info-ch.xlsx" and "src/conf/info-en.xlsx"), this function reads
the first two columns and generates a third column by concatenating the first column, "__",
and the second column. Any space in the result is replaced with a dash ("-").
"""
# List of Excel files to process
file_list = ["src/conf/info-ch.xlsx", "src/conf/info-en.xlsx"]
for file_path in file_list:
if not os.path.exists(file_path):
print(f"File does not exist: {file_path}")
continue
try:
# Assuming the Excel file does not have a header, so header=None
df = pd.read_excel(file_path, header=None)