Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running code #14

Open
mardirousi opened this issue Oct 22, 2017 · 1 comment
Open

Error when running code #14

mardirousi opened this issue Oct 22, 2017 · 1 comment

Comments

@mardirousi
Copy link

mardirousi commented Oct 22, 2017

http://tinyurl.com/go9wepf

I get this error when running the code.

Traceback (most recent call last):
File "/Users/mardirousi/Desktop/Python/Ch 9/csv/csv.py", line 1, in
import csv
File "/Users/mardirousi/Desktop/Python/Ch 9/csv/csv.py", line 5, in
write = csv.writer(f, delimiter=",")
AttributeError: module 'csv' has no attribute 'writer'

@RobertSchusterFrontEndWebDeveloper

I was having the same issue and found that if all the files were placed into the same folder as this python file, on my pc this worked. Windows 10 version. I was able to open a cvs file named "Grocery inventory.csv" and txt file named "file.txt".

chapter 9 exercise 1

import os
os.path.join("Users",
"gr8-g",
"Grocery inventory.csv")

import csv

with open("Grocery inventory.csv", "r", newline='') as f:
r = csv.reader(f, delimiter=",")
for row in r:
print(",".join(row))

with open("file.txt", "r") as f:
print(f.read())

End of script

Hope this helps Rob

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants