gevansmdes
asked on
mySQL import scripting
how do I import non-delimited data into mysql?
the column location is identified by field number
example
column 1 is fields 1 through 14
column 2 is fields 15 through 40
the column location is identified by field number
example
column 1 is fields 1 through 14
column 2 is fields 15 through 40
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
First create temparaly table
then use below code to import file
LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;
then write following code to export
SELECT Field14,Field40 INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
then Import back using following code
LOAD DATA INFILE 'result.txt' INTO TABLE persondata (Field1,Field15);
or you can use following steps
http://computeraxe.com/how-to-import-data-file-mysql-phpmyadmin/
then use below code to import file
LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;
then write following code to export
SELECT Field14,Field40 INTO OUTFILE '/tmp/result.txt'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
then Import back using following code
LOAD DATA INFILE 'result.txt' INTO TABLE persondata (Field1,Field15);
or you can use following steps
http://computeraxe.com/how-to-import-data-file-mysql-phpmyadmin/
this link help you
http://dev.mysql.com/doc/refman/5.5/en/load-data.html
http://dev.mysql.com/doc/refman/5.5/en/load-data.html
this will work
load data infile 'yourfilename.txt'
into table [Yourtablename]
fields terminated by '|'
lines terminated by '\n'
(col1,
col15,
@col14,
@col40)
load data infile 'yourfilename.txt'
into table [Yourtablename]
fields terminated by '|'
lines terminated by '\n'
(col1,
col15,
@col14,
@col40)
Please post a representative example of the data in the code snippet (or attach a file). Once we can see exactly what sort of thing you have we can probably offer some concrete suggestions. Thanks, ~Ray
ASKER
thank you
LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;