Created
June 12, 2012 15:08
-
-
Save baisong/2918079 to your computer and use it in GitHub Desktop.
Example import using fgetcsv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (($handle = fopen($filepath, "r")) == FALSE) { | |
echo ("Error loading CSV file '" . $filepath . "'. Import failed."; | |
return; | |
} | |
echo 'Processing CSV file for import...'; | |
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | |
$columns = count($data); | |
$row++; | |
if (empty($data[0])) { | |
echo ('No data in row ' . $row, 'error'); | |
continue; | |
} | |
// Process row | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment