Import large CSV data via PHP

Importing large data may cause Memory problems or timeout problems, here is how to avoid these problems.

$file = $_FILES['file']['tmp_name'];
        $handle = fopen($file, "r");
        while (($row = fgetcsv($handle, 0, ",")) !== FALSE) {
            // $row contains all the columns in a line in csv
            // insert into students(column1..., column2..., column3....) values($row[0],$row[1],$row[2]........)
         }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s