How to implement guide with csv writing in python 3.9: extra newline added when using dictwriter
I'm confused about I'm working with a question while trying to write a list of dictionaries to a CSV file using Python 3.9's `csv.DictWriter`. I expect the output to be a clean CSV without any extra newlines between rows, but I end up with blank rows in my output. Here's a simplified version of my code: ```python import csv data = [ {'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25} ] with open('output.csv', mode='w', newline='') as file: writer = csv.DictWriter(file, fieldnames=['name', 'age']) writer.writeheader() writer.writerows(data) ``` I have explicitly set `newline=''` in the `open` function to prevent extra newlines, but the resulting `output.csv` still contains empty lines. When I open this CSV in Excel, it shows a blank row after each entry, which is quite frustrating. I've tried different approaches, including removing the `newline=''` parameter, but that leads to other formatting issues. Additionally, when I check `output.csv` in a text editor, it appears to have the correct content without visible extra lines, but Excel interprets it differently. Is there a specific behavior of `csv.DictWriter` in Python 3.9 that could lead to this scenario? How can I resolve this to get a clean CSV file without extra blank rows? I'm working with Python in a Docker container on Ubuntu 20.04. Any suggestions would be helpful.