title: How do I find the row number for a specific item in a CSV file in Python?
body: <p>I have been looking for a solution but I haven't found one yet. So, I'm trying to find the row number of a specific input in my csv file. For example, let this be the csv file I'm parsing -</p>
  
  <pre><code>a
  b
  c
  d
  </code></pre>
  
  <p>This is a file with 100 rows and 1 column. So I give in the input "d" and I should get 4. I tried this code but it gives me None -</p>
  
  <pre><code>def find_index(input):
      o = open('products.csv', 'rU')
      myData = csv.reader(o)
      index = 0
      for row in myData:
          if row == input:
              return index
          else : index+=1
  </code></pre>
  
  <p>I'm new with the csv module, so please forgive me if I'm being stupid. Thanks!</p>
  
  <p>EDIT - I tried everyone's solution and all of them just return None. What could be wrong? Is it the 'rU' flag? Because if I remove that, I get this error -
      for row in myData:</p>
  
  <pre><code>Error: new-line character seen in unquoted field - do you need to open the file in universal-newline mode?
  </code></pre>