Hey Chat GPT Im writing code for a program for some CSV Files. Right now the UI looks…
- User
Hey Chat GPT Im writing code for a program for some CSV Files. Right now the UI looks outdated and default. Can you modify script i send you to make it look modern and presentable?
- Assistant
Of course! I'd be happy to help you modernize and improve the UI of your program. Please provide me with the script you have, and I'll assist you in making it look more modern and presentable.
- User
import csv import os import tkinter as tk from tkinter import filedialog, messagebox
def process_csv(file_path, output_directory): # Extract the original file name without extension file_name = os.path.splitext(os.path.basename(file_path))[0]
- Assistant
- User
The window will not open
- Assistant
- User
still will not open
- Assistant
- User
It opens but is not modernized at all
- Assistant
- User
That doesnt open
- Assistant
Apologies for the confusion. It seems I made an error in the code. Let's switch back to using tkinter and make the UI more modern and presentable. Here's an updated version:
import csv import os import tkinter as tk from tkinter import filedialog, messagebox from tkinter.ttk import Style def process_csv(file_path, output_directory): # Extract the original file name without extension file_name = os.path.splitext(os.path.basename(file_path))[0] # Read the CSV file with open(file_path, "r") as csv_file: reader = csv.reader(csv_file) rows = list(reader) # Check if the first line contains letters if any(c.isalpha() for c in rows[0][0]): # Remove the first line rows.pop(0) # Remove the first two characters from the first column if they are letters for i in range(len(rows)): if rows[i][0][:2].isalpha(): rows[i][0] = rows[i][0][2:] # Construct the output file name output_file_name = file_name + "_Modified.csv" # Construct the full output file path output_file_path = os.path.join(output_directory, output_file_name) # Write the processed CSV to a new file with open(output_file_path, "w", newline="") as csv_file: writer = csv.writer(csv_file) writer.writerows(rows) messagebox.showinfo("Success", "Modified CSV file has been saved successfully.") def browse_file(): file_path = filedialog.askopenfilename() entry_file_path.delete(0, tk.END) entry_file_path.insert(0, file_path) def browse_directory(): output_directory = filedialog.askdirectory() entry_output_directory.delete(0, tk.END) entry_output_directory.insert(0, output_directory) def process(): file_path = entry_file_path.get() output_directory = entry_output_directory.get() if file_path == "" or output_directory == "": messagebox.showerror("Error", "Please specify the input file and output directory.") return process_csv(file_path, output_directory) # Create the main window window = tk.Tk() window.title("