Echo JS 0.11.0

<~>

GustavRasmussen comments

GustavRasmussen 389 days ago. link 2 points
import csv

# Define the CSV file name
csv_file_name = "products.csv"

# Define the field names for the CSV header
field_names = ["ProductID", "ProductName", "Price"]

# Open the CSV file in write mode
with open(csv_file_name, mode='w', newline='') as csv_file:
    # Create a CSV writer
    csv_writer = csv.DictWriter(csv_file, fieldnames=field_names)
    
    # Write the header
    csv_writer.writeheader()
    
    # Write the data from the products list
    for product in products:
        csv_writer.writerow(product)