Open mardirousi opened 6 years ago
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".
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())
Hope this helps Rob
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'