gpt-4o-2024-08-06· OpenAI
WildChat-4.8M (AI2)
Fix errors and bugs in the given code, without changing its intended functionality. ONLY…
- User
Fix errors and bugs in the given code, without changing its intended functionality. ONLY return the fixed code and nothing else. Enclose the entire code in a single code block.
i have many jpg in this folder now create csv file with this format: filename, pematangan name of jpg.jpg, 1 name of jpg.jpg, 1
- Assistant
import os import csv # Replace 'your_directory_path' with the path to your directory containing the jpg files directory = 'your_directory_path' # Open a CSV file for writing with open('output.csv', 'w', newline='') as csvfile: fieldnames = ['filename', 'pematangan'] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) # Write the header writer.writeheader() # Iterate through files in the directory for filename in os.listdir(directory): if filename.endswith('.jpg'): # Write the file name and pematangan value to the CSV writer.writerow({'filename': filename, 'pematangan': 1})