I am trying to configure the import of a large csv file into the database But I have a problem with delimiter in csv file The standard replacement methods for some reason do not work for me, maybe someone knows other solutions to this problem I will be very grateful for help.
This is my code in ImportController
$file = file($request->file->getRealPath());
$data = array_slice($file, 1);
$parts = str_replace(';', ',', (array_chunk($data, 5000)));
foreach ($parts as $index => $part)
{
$fileName = resource_path('upload/csv/balance/' . date('y-m-d-H-i-s') . $index . '.csv');
file_put_contents($fileName, $part);
}
(new ImportBalance())->importToDb();
return redirect()->route('admin.balance');
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2TL4htY
via IFTTT
Aucun commentaire:
Enregistrer un commentaire