title: What is the fastest way to search the csv file?
body: <p>Task: Check the availability of the series and passport number in the file.</p>
  
  <p>My decision is as follows:</p>
  
  <pre class="lang-py prettyprint-override"><code>def check_passport(filename, series: str, number: str) -&gt; dict:
      """
      Find passport number and series
      :param filename:csv filename path
      :param series: passport series
      :param number: passport number
      :return:
      """
      print(f'series={series}, number={number}')
      find = False
      start = datetime.datetime.now()
      with open(filename, 'r', encoding='utf_8_sig') as csvfile:
          reader = csv.reader(csvfile, delimiter=',')
          try:
              for row in reader:
                  if row[0] == series and row[1] == num:
                      print(row[0])
                      print(row[1])
                      find = True
                      break
          except Exception as e:
              print(e)
      print(datetime.datetime.now() - start)
      if find:
          return {'result': False, 'message': f'Passport found'}
      else:
          return {'result': False, 'message': f'Passport not found in Database'}
  </code></pre>
  
  <p>This is part of the csv file</p>
  
  <pre><code>PASSP_SERIES,PASSP_NUMBER
  3604,015558 
  6003,711925 
  6004,461914 
  6001,789369
  </code></pre>
  
  <p>If you do not have your passport in the file, the time is worse, as you need to check all the lines. My best time is 53 seconds.</p>