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?
The Python "NameError: name is not defined" occurs when we try to access a variable or function that is not defined or before it is defined. To solve the error, make sure you haven't misspelled the variable's name and access it after it has been declared.
NameError is a kind of error in python that occurs when executing a function, variable, library or string without quotes that have been typed in the code without any previous Declaration. When the interpreter, upon execution, cannot identify the global or a local name, it throws a NameError.
quotechar specifies the character used to surround fields that contain the delimiter character. The default is a double quote ( ' " ' ). escapechar specifies the character used to escape the delimiter character, in case quotes aren't used. The default is no escape character.
csv
is not a builtin, although it's part of the standard library. You need to import it:
import csv
# your code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With