Search Marketing

   
   

Import Tab-Delimited Text File Data into MySQL Database Table

Wed Dec 19, 2012 8:37 pm
<<     >>
Comments: 1 Views: 9435

Data saved in excel or other spreadsheet formats can easily be feed into a MySQL table using the Load Data function.

The first thing to do is save/export your data from your spreadsheet in a tab-delimited format. Here is an example:

"John Doe" "1111 test St" "555-555-5555"
"Jane Doe" "1111 test St" "555-555-5555"

If you had a text file with each piece of data seperated by tabs, and a new row of information on each line, you can easily import this data into a MySQL table.

Example Table:

create table customers(
ID int not null auto_increment primary key,
Name char(100),
Address char(100),
Phone char(12)
);

To get your text file data into the MySQL table about you would run this command in MySQL.

mysql > Load Data local Infile '/customer.txt' into table db.customer fields terminated by 't' enclosed by '"' lines terminated by 'rn';

Note: rn mean new lines. r means carriage return. n means new line.



Comments
Wed Dec 26, 2007 9:09 am
Name: Geek Hohoho | Url: http://www.jihe.net| Comment: Good piece of information. However, since the example text file contains three columns only, the table has to have the corresponding three fields in the correct order. That is,

create table customers(
Name char(100),
Address char(100),
Phone char(12)
);



Name:
*
URL: http: (ex. cnn.com)
Comment:
*
Number:
Math (26 + 5)
* required
SubCategories
Books

© 2017 Christonium LLC

Christonium.com
|
Terms of Use
|
Privacy
ccc