Skip to content Skip to sidebar Skip to footer

Python Csv Import Fails

So I'm trying to use the csv module in python 3.3.2 but I am getting this error. Traceback (most recent call last): File 'C:\Users\massi_000\Desktop\csv.py', line 1, in &

Solution 1:

You have named your file csv.py and this clashes with the csv module from the Python standard library.

You should rename your own file to something else so that import csv will import the standard library module and not your own. This can be confusing but this is a good rule-of-thumb going forward: avoid giving your own Python files names that are the same as modules in the standard library.

Solution 2:

As @Simeon Visser said, you have to rename your file but you have some other issues with your code as well. Try this:

import csv
withopen('test.csv', newline='') as f:
    reader = csv.reader(f, delimiter=' ')
    for row in reader:
        print (', '.join(row))

Post a Comment for "Python Csv Import Fails"