title: Python CSV touble
body: <p>I writing a code that reads a very large CSV file line by line with readlines(). I call the function with a global variable and access that variable to search for specific words and count the number of times it comes up in the file.</p>
  
  <pre><code>def init(filename):
      global lines
      with open(filename) as file:
          lines = file.readlines()
  
  
  def total():
      males = 0
      females = 0
      for i in range(0, len(lines)):
          current_line = lines[i].split(",")
          if current_line[5] == 'M\n':
              males += 1
          elif current_line[5] == 'F\n':
              females += 1
  
      total_dict = {"Gender": {"M": males, "F": females}}
      return total_dict
  </code></pre>
  
  <p>for some reason this code works with smaller file, but I can't seem to get to work with a super large one.</p>