![]() |
mysql import from text file
i have some text files that i want to import in mysql..
fields are delimitated by "|" first row contain the columns name is there any possibility to import them directelly to mysql without creating the tables first? tables must be autocreated from first line in the moment of the import.. i know there is mysqlimport utility but require that tabels to be already created before the import.. :( |
Why would you possibly need it to autocreate from the first line going in?
|
I think you need a little script (PHP, Perl, ...) that reads the text file and creates the SQL commands for adding the tables and insert the content.
|
Creating the tables can be done with various command line tricks or simple scripts, but the fact is, what is data, if it is not scoped correctly.. ints, text, vars, etc and placed in properly named fields, or in you're explanation "columns"
|
bump for info :)
|
Quote:
|
Look up "load data infile".... off the top of my head, and not checking syntax, it would look something like:
mysql>load data in file 'data.txt' into table [table_name] fields terminated by '|' lines terminated by '\n' ignore 1 lines |
Quote:
good thing you've read the thread first |
Quote:
Forgot the table create statement. |
| All times are GMT -7. The time now is 05:17 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123