title: Best way to access the Nth line of csv file
body: <p>I have to access the Nth line in a CSV file.</p>
  
  <p>Here's what I did:</p>
  
  <pre><code>import csv
  
  the_file = open('path', 'r')
  reader = csv.reader(the_file)
  
  N = input('What line do you need? &gt; ')
  i = 0
  
  for row in reader:
      if i == N:
          print("This is the line.")
          print(row)
          break
  
      i += 1
  
  the_file.close()
  </code></pre>
  
  <p>...but this does not feel optimal. Edit for precision: If the file is huge, I do not want to go through all the lines and I do not want to have to load the whole file into memory.</p>
  
  <p>I do hope something like <code>reader[N]</code> exists, but I have not found it.</p>
  
  <p>Edit for answer: This line (coming from chosen answer) is what I was looking for:</p>
  
  <pre><code>next(itertools.islice(csv.reader(f), N, None)
  </code></pre>