|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Join Date: Jun 2002
Location: france
Posts: 996
|
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.. |
|
|
|
|
|
#2 |
|
Confirmed User
Join Date: Apr 2006
Location: Easy Webcam Pro
Posts: 1,213
|
Why would you possibly need it to autocreate from the first line going in?
__________________
[email protected] |
|
|
|
|
|
#3 |
|
Confirmed User
Join Date: Sep 2005
Location: Zurich
Posts: 1,045
|
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.
|
|
|
|
|
|
#4 |
|
So Fucking Banned
Join Date: Jan 2005
Location: At My Desk
Posts: 2,904
|
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"
|
|
|
|
|
|
#5 |
|
PostMaster General
Join Date: Aug 2006
Posts: 10,781
|
bump for info
__________________
|
|
|
|
|
|
#6 | |
|
Confirmed User
Join Date: Apr 2006
Location: Easy Webcam Pro
Posts: 1,213
|
Quote:
__________________
[email protected] |
|
|
|
|
|
|
#7 |
|
Confirmed User
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
|
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
__________________
Your post count means nothing. |
|
|
|
|
|
#8 | |
|
Confirmed User
Join Date: Apr 2002
Location: /root/
Posts: 4,997
|
Quote:
good thing you've read the thread first |
|
|
|
|
|
|
#9 | |
|
Confirmed User
Join Date: Apr 2003
Location: Loveland, CO
Posts: 5,526
|
Quote:
Forgot the table create statement.
__________________
Your post count means nothing. |
|
|
|
|