9

What settings do you need to choose for phpmyadmin to import a tab delimited file? There are no enclosures or end of line markers.

Something like:

Title 1 Title 2 Title 3
item1   item2   item3

I used to know how to do such a simple task, but have now worked with phpmyadmin for ages and can't even find my answer on google. Every search result gives the settings for normal CSV files.

Functino
  • 1,939
  • 17
  • 25
user2231688
  • 195
  • 1
  • 3
  • 15
  • GoTo your Import tab in phpmyadmin and chk this screenshot http://i.imgur.com/TTyeRhH.jpg ..Select the format and fill the below settings – swapnesh May 28 '13 at 05:58
  • Hi, thanks for your quick reply. But i meant, the bit under it, ie the settings. – user2231688 May 28 '13 at 06:01
  • 5
    you can choose \t for tab delimited like wise..also chk this http://stackoverflow.com/questions/1302046/how-to-import-delimited-data-into-mysql-in-phpmyadmin – swapnesh May 28 '13 at 06:07
  • `Let me know if something still unclear` – swapnesh May 28 '13 at 06:08
  • oh dear silly me. Thats one of the first posts i saw. Shame i didnt scroll down to the bottom. – user2231688 May 28 '13 at 06:13
  • but i am now getting an error as follows: "#1452 - Cannot add or update a child row: a foreign key constraint fails (`icecatpim`.`category`, CONSTRAINT `category_ibfk_1` FOREIGN KEY (`pcatid`) REFERENCES `product` (`product_id`) ON DELETE CASCADE ON UPDATE CASCADE) " – user2231688 May 28 '13 at 06:14
  • Its ok..we all make mistakes..np :) – swapnesh May 28 '13 at 06:14
  • without much info ..hard to tell..but a quick google give me this..chk this http://stackoverflow.com/questions/1253459/mysql-error-1452-cannot-add-or-update-a-child-row-a-foreign-key-constraint-fa – swapnesh May 28 '13 at 06:16
  • thanks for all your quick replies. @swapnesh (or anyone else) what info would you need to help me, and i will do my best so that i dont waste all your time? – user2231688 May 28 '13 at 06:28
  • If you have a foreign key relationship with some kind of cascading action, you need to make sure that the id of the item you are entering (in the relationship table) actually exists in the parent table. MySQL checks the foreign keys to make sure there is an originating value. It is just a way to reinforce the integrity of the table. – swapnesh May 28 '13 at 06:34

1 Answers1

3

LOAD DATA INFILE has a column-specification at the end.

LOAD DATA INFILE ... 
INTO TABLE ... 
FIELDS TERMINATED BY '\t'
IGNORE 1 LINES;

You need to use \t as your field terminator for a tab separated file.

load data local infile 
'C:/Users/rocket/Documents/filipe ferminiano/processos/segmentacao/912013/coplaint.csv'
into table crm_base.coplaints fields terminated by '\t' enclosed by '"';
Xman Classical
  • 5,179
  • 1
  • 26
  • 26