title: CSV Module AttributeError
body: <p>So I copied and pasted a demo program from the book I am using to learn Python:</p>
  
  <pre><code>#!/usr/bin/env python
      import csv
  total = 0
  priciest = ('',0,0,0)
  r = csv.reader(open('purchases.csv'))
  for row in r:
      cost = float(row[1]) * float(row[2])
      total += cost
      if cost == priciest[3]:
          priciest = row + [cost]
  print("You spent", total)
  print("Your priciest purchase was", priciest[1], priciest[0], "at a total cost of", priciest[3])
  </code></pre>
  
  <p>And I get the Error: </p>
  
  <pre><code>Traceback (most recent call last):
        File "purchases.py", line 2, in &lt;module&gt;
          import csv
        File "/Users/Solomon/Desktop/Python/csv.py", line 5, in &lt;module&gt;
          r = csv.read(open('purchases.csv'))
  AttributeError: 'module' object has no attribute 'read'
  </code></pre>
  
  <p>Why is this happening? How do I fix it?
  <i>
  Update:
  <b>Fixed All The Errors</b>
  Now I'm getting:</p>
  
  <pre><code>Traceback (most recent call last):
    File "purchases.py", line 6, in &lt;module&gt;
      for row in r:
  _csv.Error: line contains NULL byte
  </code></pre>
  
  <p>What was happening in terms of the CSV.py:
  I had a file with the same code named csv.py, saved in the same directory. I thought that the fact that it was named csv .py was screwing it up, so I started a new file called purchases.py, but forgot to delete csv</i></p>