简体   繁体   中英

Import txt file into MySQL database

Hi how can I import that kind of text file into MySQL data base Thanks in advance from Quebec City :)

"8638671",1,1,"SAL",,,"12.8x16.9 P",,"RC","PFLO",,,
"8638671",2,2,"CUI",,,"10.11x12.6 P",,"RC","LINO",,,
"8638671",3,3,"SDB",,,"3.11x7.3 P",,"RC","LINO",,,
"8638671",4,4,"CCP",,,"8.6x10.2 P",,"RC","LINO",,,
"8638671",5,5,"SDL",,,"5.6x4.4 P",,"RC","LINO",,,
"8640420",1,1,"HAL",,,"5.5x3.3 P",,"RC","CERAM",,,
"8640420",2,2,"SAL",,,"11.1x21.8 P",,"RC","PFLO",,,
"8640420",3,3,"SAM",,,"9x11 P",,"RC","PFLO","porte-patio",,
"8640420",4,4,"CUI",,,"8x7.5 P",,"RC","CERAM",,,
"8640420",5,5,"SDB",,,"5x8 P",,"RC","CERAM",,,
"8640420",6,6,"SDL",,,"5x7.5 P",,"RC","LINO",,,
"8640420",7,7,"CCP",,,"11.5x13 P",,"RC","PFLO",,,
"8640420",8,8,"CAC",,,"9x10 P",,"RC","PFLO",,,
"8640420",9,9,"CAC",,,"7.5x9.10 P",,"RC","PFLO",,,
"8672024",1,1,"CUI",,,"10x8 P",,"RC","AU",,,
"8672024",2,2,"SAM",,,"15x10 P",,"RC","AU",,,

For importing the file, use any server like wamp,xampp. They have the facility called phpMyAdmin which is the GUI for mysql. You can easily import any SQL file from there. Apart from importing the file, it provides many other featues.

1: Open this file in excel, at the time opening the file it will ask you for format. Add there , .
2: save that file in .csv format.
3: Create your database schema and
4: import .csv file through phpMyAdmin

Use command like this :

LOAD DATA LOCAL INFILE 'folder/myFile.txt' INTO TABLE myTable (field1, field2, field3, field4);

More info following the @Nemoden link : http://dev.mysql.com/doc/refman/5.1/en/load-data.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM