importing data from csv (phpmyadmin error: duplicate entry)

This subforum is for issues specific to importing or maintaining product databases, e.g. using phpMyAdmin.

importing data from csv (phpmyadmin error: duplicate entry)

Postby k8inmd » Thu Sep 18, 2014 11:57 am

hi - i was able to get an excel spreadsheet imported but each line error ed so nothing came up - here's the error message when I try again. I am only trying to upload description and price...

Error
SQL query:

INSERT INTO `private_catonsvillecm` ( `description` , `price` )
VALUES (

'Center Smoked Cut Ham Steaks', '$9.75 '
)
MySQL said: Documentation

#1062 - Duplicate entry '' for key 'PRIMARY'

Please advise
Kathleen
k8inmd
 
Posts: 20
Joined: Sat Oct 12, 2013 4:00 am

Re: importing data from csv

Postby support » Thu Sep 18, 2014 12:24 pm

Item codes are mandatory and must be unique, so you must also specify values for the code column. The error you got is telling you that, just not so obviously. When you leave off code, it tries to set them all to NULL, but it can't because they must be unique, so it fails on the second row trying to set an item code to NULL when there already is one.

Also, I am moving this topic to the Product database subforum, since that is for phpMyAdmin and other database questions.
support
 
Posts: 566
Joined: Sun Mar 11, 2012 9:06 am

Re: importing data from csv (phpmyadmin error: duplicate ent

Postby k8inmd » Thu Sep 18, 2014 12:33 pm

so in my excel spreadsheet that has two columns, description and price, how do I get it an item code? is there an auto generate options for sequential number or an easy way to do this?
k8inmd
 
Posts: 20
Joined: Sat Oct 12, 2013 4:00 am

Re: importing data from csv (phpmyadmin error: duplicate ent

Postby support » Thu Sep 18, 2014 12:48 pm

Your spreadsheet program should be able to add an autoincrement column, but I'm not exactly sure how.

How many items are there? If not too many, you could just invent them yourself? Generally it is better not to use an autoincrement, because then in the next database you may have different items sharing the same item code as the last version of the database. This can cause problems if your order is not completely empty (archived, without any recurring orders) when you update the database.

The vendor doesn't use or doesn't give you their own item codes?
support
 
Posts: 566
Joined: Sun Mar 11, 2012 9:06 am

Re: importing data from csv (phpmyadmin error: duplicate ent

Postby andrewd » Mon Nov 23, 2015 7:32 pm

Having the same issue. Every time i change an item code, re-save the csv file, (after getting the error message) and re-import it, up pops the same error for a different product. After using the find function in excel, i'm not able to find any duplicate codes anywhere for the products showing error codes. But once i change the product code it no longer hits on that product, it just goes to the next product that doesn't have a real duplicate, yet says it does.
andrewd
 
Posts: 4
Joined: Sun Aug 16, 2015 8:02 pm

Re: importing data from csv (phpmyadmin error: duplicate ent

Postby support » Mon Nov 23, 2015 7:52 pm

You should be clearing the database in between runs. If you aren't, then it leaves a partial import after each run, so the next import of the same csv file will hit a duplicate item on the very first item.

If you are clearing the database, then I'd ask, are you sure the item codes are unique in the file? Try sorting the csv file by item code, and then it should be easy to see the duplicates.
support
 
Posts: 566
Joined: Sun Mar 11, 2012 9:06 am

Re: importing data from csv (phpmyadmin error: duplicate ent

Postby andrewd » Mon Nov 23, 2015 8:04 pm

Thanks! I hadn't cleared out the last database. That makes sense. Appreciate the feedback. Any reference links on how to clear?
andrewd
 
Posts: 4
Joined: Sun Aug 16, 2015 8:02 pm

Re: importing data from csv (phpmyadmin error: duplicate ent

Postby support » Mon Nov 23, 2015 11:19 pm

Already e-mailed you this, but posting here for reference by other users who might read this topic in the future:

How to clear private database in phpmyadmin:
http://foodclub.org/wiki/Foodclub:Docum ... ew_file.3F
support
 
Posts: 566
Joined: Sun Mar 11, 2012 9:06 am


Return to Product database

Who is online

Users browsing this forum: No registered users and 2 guests

cron