mongodb uploading csv php code example
Example: mongodb uploading csv php
test->cartoons;
$row = 1;
$handle = fopen(dirname(Yii::app()->request->scriptFile).'/images/importcsv/upload.csv', "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo " $num fields in line $row:
\n";
$row++;
$users = array();
for ($c=0; $c < $num; $c++) {
echo 'data--'.$data[$c] . "
\n";
}
$users[] =$data;
var_dump($users);
$collection->batchInsert($users);
}
?>