DotDragnet
February 08, 2012, 11:10:55 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Welcome to the new trading eye refugees
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: CSV import to MySQL via phpMyAdmin  (Read 1270 times)
orydian
Hero Member
*****
Posts: 1230



orydian
View Profile Awards
« on: February 17, 2010, 05:20:04 PM »

Okay, this is driving me round the bend. I'm trying to import a single column/field into MySQL.

CSV looks like this...

"Name A",
"Name B",
"Name C",
and so on.

I'm trying to import it into a table with a field called 'name'.

I locate the correct table via phpMyAdmin and click to import the file with the following settings...

Fields terminated by = ,
Fields enclosed by = "
Fields escaped by = \
Lines terminated by = auto
Column names = name

Then I click Go, but I always get a "Invalid field count in CSV input on line 1." error.

I'm very knew at this, and I'm clearly doing something wrong, but I've no idea what the problem is. If anyone could help with this, I'd really appreciate it.

ory.
Logged

ory like lorry, not ory like story - twitter | tumblr
sarahA
DDN Contribs
Hero Member
*****
Posts: 2123



View Profile WWW Awards
« Reply #1 on: February 17, 2010, 07:56:29 PM »

Set lines terminated by as /n/r and open the file you're importing and check there are no extra columns (ie. there's not any commas if you only have one column), and that there are no blank lines smile
Logged

JasonD
Global Moderator
Hero Member
*****
Posts: 529



View Profile Awards
« Reply #2 on: February 17, 2010, 08:00:23 PM »

You have a comma at the end of the line so it will want to insert an empty value into a second column.

Remove the commas from the file, or add a column to fill with the nothing and remove it when you are done.
Logged
orydian
Hero Member
*****
Posts: 1230



orydian
View Profile Awards
« Reply #3 on: February 17, 2010, 08:23:23 PM »

Cheers guys. I'll try it out.

ory.
Logged

ory like lorry, not ory like story - twitter | tumblr
orydian
Hero Member
*****
Posts: 1230



orydian
View Profile Awards
« Reply #4 on: February 17, 2010, 08:30:54 PM »

Yes! Removing the commas did the trick.

Thank you both very much indeed. big grin

ory.
Logged

ory like lorry, not ory like story - twitter | tumblr
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!