Why are you splitting the csw in the first place?
You should just upload it and then register a job that imports it into the database.
Hello All, I am trying to upload large csv so i am looping through file and split every 1000 lines into seperate files. now i am trying to insert each file like below,
$path = base_path("resources/pendingcontacts/*.csv");
$g = glob($path);
//run 2 loops at a time
foreach (array_slice($g,0,2) as $file) {
//read the data into an array
$data = array_map('str_getcsv', file($file));
$insertlist = [];
//loop over the data
foreach($data as $row) {
$insertlist[] = ['email' => $row[0]];
}
// dump(count($insertlist));
ContactEmail::insert($insertlist);
//delete the file
unlink($file);
}
return true;
Above query is working fine but the problem is above query runs only 2 files and returns true
example i have 10 files in above path but after executing two files it is not running 3rd file instead it returns true. How to alter above code?
Please or to participate in this conversation.