title: How to handle large CSV files to insert into mysql
body: <p>I have a file a csv file (made as .txt) that I am currently parsing right now, but the file is about 350mb uncompressed. When it's zipped, it shows in the zip file as 23mb. My system completely freezes when I try to parse the 350mb file. I store the lines in an array like this. The first row are the headings. </p>
  
  <pre><code>$fh = fopen($inputFile, 'r');
      $contents = fread($fh, filesize($inputFile)); // 5KB
  fclose($fh);
  //$contents = str_replace('"','',$contents);
  
  $fileLines = explode("\n", $contents); // explode to make sure we are only using the first line.
  </code></pre>
  
  <p>Then I go through each line to insert it in a loop into mySQL. Since the file is about 350mb, would there be a way to parse it from the .zip file like .zip_filename.txt or would that even make a difference at all? </p>
  
  <p>The file is too large to insert directly into mysql through the import method. </p>