<|im_start|>system
You are a helpful AI assistant.<|im_end|>
<|im_start|>user
Write me a python code that processes a CSV file with the following structure ["Name","URL","Rating"], download each image under the URL row as save as PNG, use the Name as the file name and save it under a subfolder using the Rating as name, add a tkinter GUI to let me choose the CSV file and output path.<|im_end|>
<|im_start|>assistant
Here's a Python program with a TkInter GUI for downloading images specified in a CSV file with your provided format. Please note that the program requires the Requests library to be installed. You can install this library with, for example, the pip utility.

```python
import csv
import pathlib
import tkinter as tk
from tkinter.filedialog import askopenfilename, askdirectory
from tkinter import ttk, messagebox

import requests


class DownloadWindow:
    def __init__(self):
        self.csvfile = None
        self.outdir = None
        self.root = tk.Tk()
        self.root.geometry("200x100")
        self.filechoosebutton = ttk.Button(self.root, text='Choose CSV file', command=self.choose_file)
        self.filechoosebutton.pack()
        self.dirchoosebutton = ttk.Button(self.root, text='Choose output directory', command=self.choose_dir)
        self.dirchoosebutton.pack()
        self.runbutton = ttk.Button(self.root, text='Download files', command=self.download)
        self.runbutton.pack()

    def choose_file(self):
        self.csvfile = askopenfilename()

    def choose_dir(self):
        self.outdir = askdirectory()

    def download(self):
        if self.csvfile is None or self.outdir is None:
            messagebox.showerror(title='Error', message='CSV file or output path not provided!')
            return

        with open(self.csvfile, 'r') as file:
            reader = csv.reader(file)
            for line in reader:
                self.download_one(*line)

    def download_one(self, name, url, rating):
        output_directory = pathlib.Path(self.outdir) / rating
        output_directory.mkdir(parents=True, exist_ok=True)
        output_file = output_directory / f'{name}.png'
        response = requests.get(url)
        with open(output_file, 'wb') as out:
            out.write(response.content)

    def run(self):
        self.root.mainloop()


def main():
    download_window = DownloadWindow()
    download_window.run()


if __name__ == '__main__':
    main()
```<|im_end|>
<|im_start|>user
I realized that I actually need to process multiple csvs at once, can you change the code to allow me to do that?<|im_end|>
<|im_start|>assistant
Sure, I can change the code so that it can process multiple csv files at once.
Here is the altered code:
```
import csv
import requests
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox
from tkinter import simpledialog

def process_csv(csv_file, output_path):
    with open(csv_file, "r") as file:
        reader = csv.reader(file)
        header = next(reader) # skip the header row
        for row in reader:
            name, url, rating = row
            response = requests.get(url)
            if response.status_code == 200:
                subfolder = output_path + "/" + rating
                if not os.path.exists(subfolder):
                    os.makedirs(subfolder)
                file_path = subfolder + "/" + name + ".png"
                with open(file_path, "wb") as f:
                    f.write(response.content)
            else:
                messagebox.showerror("Error", f"Failed to download {name} from {url}")

def select_csv():
    csv_file = filedialog.askopenfilename(initialdir = "/", title = "Select CSV file", filetypes = (("CSV files", "*.csv"), ("all files", "*.*")))
    if csv_file:
        return csv_file

def select_output_path():
    output_path = filedialog.askdirectory(initialdir = "/", title = "Select output path")
    if output_path:
        return output_path

root = tk.Tk()
root.withdraw()
csv_file_number = simpledialog.askinteger("Number of files to open", "How many files do you want to open?")
for i in range(csv_file_number):
    csv_file = select_csv()
    if csv_file:
        output_path = select_output_path()
        if output_path:
            process_csv(csv_file, output_path)
            messagebox.showinfo("Success", "Processing completed")
```
The new program uses the tkinter library's simpledialog module to ask the user how many files they wish to open, and then it runs the main body of the program that amount of times.<|im_end|>