FW: [PHP] Rewriting a textfile for import into a db..
| From: | Ryan Christensen | Date: | Wed, 08 Aug 2001 00:19:02 +0000 |
| Subject: | FW: [PHP] Rewriting a textfile for import into a db.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-61726@lists.php.net to get a copy of this message | ||
Nevermind.. I discovered that this feature was built into MySQL already!
Here's the cmd I'm using:
LOAD DATA LOCAL INFILE '/home/user/whatever.txt' INTO TABLE Table FIELDS
TERMINATED BY '|' ENCLOSED BY '\"' ESCAPED BY '\\' LINES
TERMINATED BY
'\n'
.. for anyone who might have been looking for the same thing.
Thanks!
Ryan
> -----Original Message-----
> From: Ryan Christensen [mailto:ryan@devnut.com]
> Sent: Tuesday, August 07, 2001 3:34 PM
> To: php-general@lists.php.net
> Subject: [PHP] Rewriting a textfile for import into a db..
>
>
> I have a few thousand entries that have been (until now)
> stored in text-files that I need to get imported into a MySQL
> database for a new system I'm writing that makes use of them.
> So.. the long and short of it, I was wondering if someone
> could help me write a script (or supply me with one.. Perl
> I'm guessing would be easiest) that can turn each line in the
> text file from:
>
> 123|blah|foo|bar|etc
>
> To be formatted like:
>
> INSERT INTO Table VALUES
> (123,'blah','foo','bar','etc');
>
> Thanks in advance.. any help would be appreciated!
>
> Ryan
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail:
> php-general-help@lists.php.net To contact the list
> administrators, e-mail: php-list-admin@lists.php.net
>
>