Advertisement
dereksir

Untitled

Aug 29th, 2023
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. def write_to_csv(product_data):
  2.     # Open the CSV file for writing
  3.     with open('products.csv', 'w', newline='', encoding='utf-8') as csvfile:
  4.         # Define the field names for the CSV header
  5.         fieldnames = ['Product Name', 'Price']
  6.          # Create a DictWriter object
  7.         writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement