Open utterances-bot opened 4 years ago
data are inserting into database , can you tell why it is happen ?
it was only stored in pendingcontacts folder not inserting
Do you have the 2nd console script to process the pendingcontacts?
No..Actually Data is not inserting in database just stored in pendingcontacts ,but i don't know why is not inserted in database.
the first console script only stored the contacts into csv files, the second script is used to go through the csv files in insert them in batches.
But in my case 2nd script not work , only 1st script work it stored csv files but not inserting ..Can You send Me Full Source Code on abhinavmule123@gmail.com here.
Ahh I misread this. There is only 1 console script.
This:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Contact;
class importContacts extends Command
{
protected $data;
/**
* The console command name.
*
* @var string
*/
protected $name = 'import:contacts';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Import contacts from an array.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$path = base_path("resources/pendingcontacts/*.csv");
foreach (array_slice(glob($path),0,2) as $file) {
$data = array_map('str_getcsv', file($file));
foreach($data as $row) {
Contact::updateOrCreate([
'email' => $row[0],
], ['email' => $row[0]]);
}
unlink($file);
}
}
}
You may need to tweak the $row[0] parts to point to the right column of the CSV where the email address is stored. This example assumes the first column is the email address.
This script works perfectly when data is small like 10K-15K rows in csv file. I am trying to import a csv data which have 10 million rows in Laravel, it throws s post max size issue. I just want to upload huge csv without altering any PHP ini setting. Any help?
Thanks.
Everything went fine. The artisan command works perfectly when I do it manually. Also, the scheduler pushes the command to run (found out by log entries), but doesn't make any database entries.
What is happening here?
php artisan schedule:run throws this:
Running scheduled command: "C:\xampp\php\php.exe" "artisan" import:questions > "NUL" 2>&1
and Laravel Version is 5.x.x
Good evening sir, really thank you for this tutorial. I cannot insert into database. files are always stored in the "resources / pendingcontacts" file. Help me correct the problem. thank you
can anybody tell me how i can store data from resource pendingcontact folder to mysql database
Laravel import large CSV file - DC Blog
I recently had to import a 30,000 line CSV file, in this post, I document how I tackled this...
https://dcblog.dev/laravel-import-large-csv-file