Petru Lebada
Petru Lebada

Reputation: 1682

Importing a txt file in mysql

I want to import a txt file in mysql table,and i'm wondering if there is a way to delimitate the data by a character so i can use it as column name.As an example:

My txt file data:

Column1=Yo
Column2=Hey
Column3=Wasup

I need to use the string until '=' as column name in mysql:

Column1  Column2  Column3

 Yo       Hey      Wasup

And also how to avoid importing the data between '[]' ?

Upvotes: 0

Views: 62

Answers (1)

Phate01
Phate01

Reputation: 1795

I guess that the only built-in command to import a file is LOAD DATA INFILE, which can load a file that represent the table this way:

Column1,Column2,Column3
Data1,Date2,Date3

Example:

LOAD DATA INFILE 'yourfile.csv' INTO TABLE YourTable;
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'

Upvotes: 1

Related Questions