human
次の構造["name"、 "url"、 "rating"]を使用してCSVファイルを処理するPythonコードを書いて、pngとして保存してURL行の下の各画像をダウンロードし、名前をファイル名として使用して保存します名前として評価を使用したサブフォルダーの下で、TKINTER GUIを追加して、CSVファイルと出力パスを選択できます。
gpt
```
import csv
import requests
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox

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 = select_csv()
if csv_file:
    output_path = select_output_path()
    if output_path:
        process_csv(csv_file, output_path)
        messagebox.showinfo("Success", "Processing completed")
```
human
実際に複数のCSVを一度に処理する必要があることに気付きました。コードを変更して、それを許可できますか？
gpt
以下は、複数のCSVファイルを処理するために更新されたコードです：

```
import csv
import os
import requests
import tkinter as tk
from tkinter import filedialog
from tkinter import messagebox

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_files = filedialog.askopenfilenames(initialdir = "/", title = "Select CSV files", filetypes = (("CSV files", "*.csv"), ("all files", "*.*")))
    if csv_files:
        return csv_files

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_files = select_csv()
if csv_files:
    output_path = select_output_path()
    if output_path:
        for csv_file in csv_files:
            process_csv(csv_file, output_path)
        messagebox.showinfo("Success", "Processing completed")
```