NameError: name 'csv' is not defined

Viewed 52049

I am new to Python, and I want to write a csv file, that lists the roots of my equation. I am working on Sage. My code is :

with open('out.csv', 'w') as f:
    c = csv.writer(f)
    c.writerows(root)

The error I am getting is " NameError: name 'csv' is not defined "

Can anybody help please?

2 Answers

I was having similar error using this code:

from csv import QUOTE_MINIMAL, DictWriter

Then I edited the code to:

import csv

now it works perfectly fine for me. I am using python3.

Hope this is helpful

Related