GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   mysql import from text file (https://gfy.com/showthread.php?t=660961)

alex79 09-30-2006 12:51 AM

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.. :(

Solid Bob 09-30-2006 01:15 AM

Why would you possibly need it to autocreate from the first line going in?

FlowerKid 09-30-2006 03:33 AM

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.

teksonline 10-03-2006 12:21 AM

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"

squishypimp 10-03-2006 12:22 AM

bump for info :)

Solid Bob 10-03-2006 12:23 AM

Quote:

Originally Posted by squishypimp
bump for info :)

Page 10 already?

psili 10-03-2006 05:31 AM

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

darksoul 10-03-2006 05:38 AM

Quote:

Originally Posted by psili
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


good thing you've read the thread first

psili 10-03-2006 05:42 AM

Quote:

Originally Posted by darksoul
good thing you've read the thread first

I'm a bad person. :(

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