Link to home
Start Free TrialLog in
Avatar of gevansmdes
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
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
see below example

LOAD DATA INFILE 'data.txt' INTO TABLE db2.my_table;
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/
this will work
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
Avatar of gevansmdes
gevansmdes

ASKER

thank you