title: How to split a large csv file into multiple csv files
body: <p>We downloaded .osm file from openstreetmaps gis data and converted it into .csv file through osmconvert.exe. The csv file is of  3.5 GB of size. We tried importing it to the database through heidisql. Also tried to import the file into database using below php script</p>
  
  <pre><code>$path = "../../indiacountry.csv";
      $row = 0;
      if (($handle = fopen($path, "r")) !== FALSE) {
          while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
              $row++;
              $data_entries[] = $data ;
  
          }
          fclose($handle);
      }
      // this you'll have to expand
      foreach($data_entries as $line){
  
      $ts++;
      if ($ts&gt;0)
      {
      $ft++;
   if(mysql_query("insert into mbrace_resources.street_unit_number_india(id1) values ('".str_replace ("'","",$line [0])."')") or die("the eror ".mysql_error()));
  
   }
  
        // $db-&gt;execute($line);
      }
  </code></pre>
  
  <p>When we first tried this script, there was memory_limit error and timeout. We changed memory_limit to 4000MB and set time limit to 0. Then tried the script again, the page was blank and continuously tried to execute the script, but not a single row got inserted into the table.</p>
  
  <p>After going through all of this, we feel the only way forward was to split the csv file into multiple files. </p>
  
  <p>How shall we do it.</p>
  
  <p>Thanks in advance</p>