tags:

views:

204

answers:

2

When i try to import a CSV file into my mysql database I get this error "Invalid field count in CSV input on line 1". But i am sure that my csv file is fine. Below is the first line of the csv file and the structure of the databse:

"","[email protected]","Licia Dallolio","390","37","","",

CREATE TABLE `other_table` (
  `id` int(11) NOT NULL auto_increment,
  `email` varchar(256) default NULL,
  `name` varchar(256) default NULL,
  `opened` int(11) default NULL,
  `checked` int(11) default NULL,
  `category` varchar(256) default NULL,
  `company` varchar(256) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

If anyone can help me out with this I would be very grateful. Thanks

+2  A: 

try leaving out the first column, making it only 6 columns in your csv.

also, take the trailing comma off the end of the line

John Boker
alas, no fix. thanks though
Drew
6 columns (no identity column) and taking the trailing slash off should work, how are you importing it?
John Boker
using mysql import. it did kinda work but it mised out the email address ad shifted everything left (so name became email etc)
Drew
My apologies, It is all working great now. Thanks
Drew
I'm glad it worked!
John Boker
+1  A: 

The trailing comma on the end of the csv line means there are actually 8 fields you are trying to import.

too much php
+1. Trap for wary players, this one's bitten me before.
paxdiablo