Results 1 to 4 of 4

Thread: Import .csv into phpMyAdmin Table Column

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Import .csv into phpMyAdmin Table Column

    Hi all,

    I have a table created in phpMyAdmin, and want to import data into one of the columns, I assume I select the table and then click 'Import' > 'CSV'... When I submit this I get the following error...

    Invalid field count in CSV input on line 1.
    I created the file in Excel and saved it as a .csv I did notcie that the file just has each data on a new line, should it have comma's?

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    I think the import operation will succeed only if your tables field count matches with the field count of your CSV file. In your case you want to insert data in a number of fields in your CSV file into a single field of your table.

    Instead of using the PHPMyAdmin methods you could've developed a PHP script that does what you are looking for.

  3. #3
    Join Date
    Aug 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Is there any site where i can see how to upload csv file in phpmyadmin?

    I am very confused with

    Fields terminated by
    Fields enclosed by
    Fields escaped by
    Lines terminated by
    Column names

    Please help me.

    This is my site where i want this.

    India travel city
    India's Top Colleges

  4. #4
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Dear archana:

    What codexploiter said is correct, but if you want to use phpMyAdmin, you can probably just leave all the defaults as they are and just add the column name you want the data in. For example:

    Code:
    Fields terminated by  ;
    Fields enclosed by    "
    Fields escaped by    \
    Lines terminated by  auto
    Column names        yourcolname
    If the data is all for one field as you stated, then the csv file has the data on separate lines because it is separate records with line feeds. There would be commas between the fields if you had multiple fields per record, but you do not. So just put your column name, leave the rest alone, and give it a try. Don't be afraid to try things. Make a copy of the table if it has data in it already and play around with the copy first. You won't hurt anything.
    Last edited by kuau; 08-12-2008 at 12:00 PM. Reason: added code tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •