Reputation: 823
Here is my sql code to load csv file into database but i have lots of duplicate code generated by perl script. I want to ignore duplicate records while inserting into DB and it's work but every time it inserts one duplicate record you can see in screenshot.
load data local infile '" . public_path() . "/temp_data.csv' IGNORE INTO TABLE temp_data fields terminated by ','
enclosed by '\"'
lines terminated by '\n'
IGNORE 1 LINES
(state, city, category, business, contact, address, phone, website, email)";
$connection = mysqli_connect('localhost', 'root', '0r@ng3cr33d', 'yourserv');
Table Scheme :
Why ? i am using unique key on column email but still it's adding duplicate.
One thing i noticed when load csv into database it's picking \r word in some records, anyone know how i can ignore that ? maybe that's why it inserting second one.
Example :
1 : [email protected] 2 : [email protected]\r
Thanks
Upvotes: 0
Views: 42