Reputation: 36
I have an excel sheet. How do I import a large amount of data from excel sheet quickly? I'm using laravel package maatwebsite/excel. Do I need to chunk the data and process it, if so how do I process the data quickly?
The import which I did took around 8 seconds to load an excel sheet with 100 rows having 8 columns of data. Is that quick? I think it could be better.
Upvotes: 0
Views: 1193
Reputation: 329
So, you did not specify if the data needs to be uploaded within the laravel app or not. You can always use mysql workbench and import a csv file very quickly.
If you want to do it within a laravel app, you can create a form to upload your excel file and then use eloquent/query builder like this:
$data = array(
array('user_id'=>'person1', 'subject'=> 'math'),
array('user_id'=>'person2', 'subject'=> 'english'),
);
Model::insert($data); // Eloquent approach
DB::table('table')->insert($data); // Query Builder approach
Upvotes: 1