How to Solve NameError: name 'DictWriter' is not defined -- csv
Solution: Import the 'DictWriter' module
To Solve the error, add the following line to the top of your code.
from csv import DictWriter
For more information:
Python csv DictWriter