Update BankExcelCleaner.py

This commit is contained in:
thanhtl 2025-02-21 08:30:15 +07:00
parent c003b631ac
commit bb08c7ae00

View File

@ -31,7 +31,11 @@ df["text"] = df["text"].replace(r"[\r\n]+", " ", regex=True)
# 7. Remove "#" characters from the 'text' column # 7. Remove "#" characters from the 'text' column
df["text"] = df["text"].replace(r"#", "", regex=True) df["text"] = df["text"].replace(r"#", "", regex=True)
# 8. Prompt user for the output Excel file location # 8. Reorder columns
desired_order = ["time", "text", "url", "topReactionsCount", "viewsCount", "likes"]
df = df[desired_order]
# 9. Prompt user for the output Excel file location
output_file_path = filedialog.asksaveasfilename( output_file_path = filedialog.asksaveasfilename(
title="Save Cleaned Excel File", title="Save Cleaned Excel File",
defaultextension=".xlsx", defaultextension=".xlsx",
@ -41,6 +45,6 @@ if not output_file_path:
print("No output file specified. Exiting.") print("No output file specified. Exiting.")
exit() exit()
# 9. Write the cleaned data to a new Excel file # 10. Write the cleaned data to a new Excel file
df.to_excel(output_file_path, index=False) df.to_excel(output_file_path, index=False)
print(f"Cleaned Excel file saved to: {output_file_path}") print(f"Cleaned Excel file saved to: {output_file_path}")