Read from and write to CSV files in a straightforward manner.
Source Code
import csv
# Writing to a CSV file
with open('output.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerow(["Name", "Age"])
writer.writerow(["Alice", 24])
# Reading from a CSV file
with open('output.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
print(row)