title: Python - Searching input variable in csv file
body: <p>I'm trying to develop a code where if the input variable is in the csv file, the programa should print &quot;Encontrei&quot; (portuguese word for &quot;found&quot;) and if not , print (&quot;Não encontrei&quot;). However, this isn´t working, in the input I'm wrighting a word that I know it´s in the csv file, but I´m always getting: &quot;Não encontrei&quot;. I tryed 2 different approaches and I´m getting the same result.</p>
  <p>1st code:</p>
  <pre><code>def pilar():
      pilar = input(&quot;Perfil do pilar:&quot;)
      csv_file=csv.reader(open(r&quot;C:\Users\tomas\Documents\ISEP\5º Ano\TESE\PROGRAMA\PERFIS.csv&quot;))
      
      for row in csv_file:
          if pilar in csv_file:
              print(&quot;Pilar: &quot;, pilar)
          else:
              print(&quot;Não encontrei&quot;)
  pilar()
  </code></pre>
  <p>2nd code:</p>
  <pre><code>import csv
  
  with open(r&quot;C:\Users\tomas\Documents\ISEP\5º Ano\TESE\PROGRAMA\PERFIS.csv&quot;) as perfis:
      csv_dict_reader = csv.DictReader(perfis)
      
      for row in perfis:
          pilar = input(&quot;Pilar: &quot;)
          if pilar in perfis:
              print(&quot;Encontrei&quot;)
          else:
              print(&quot;Não encontrei&quot;)
  </code></pre>