Re: You guys will find this easy...
| From: | Cynic | Date: | Tue, 05 Dec 2000 12:20:36 +0000 |
| Subject: | Re: You guys will find this easy... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28705@lists.php.net to get a copy of this message | ||
Assuming all the files are in the ./user directory, and no other
files are there:
$d = dir( "./user" ) ;
$fp = fopen( "./to_mysql.txt" , 'w' ) ;
while( $file = $d->read() ) {
if( '.' != $file && '..' != $file ) {
$far = file( "./user/$file" ) ;
fputs( $fp , trim( $far[ 0 ] ) . ',' . trim( $far[ 1 ] ) . ',' .
trim( $far[ 2 ] ) . "\n" ) ;
} ;
}
$d->close() ;
fclose( $fp ) ;
This will yield a dump file with the contents of the files on
one row each, separated by comma. You can easily import this
into into MySQL using loaddata.
At 08:53 5.12. 2000, jalist wrote the following:
--------------------------------------------------------------
>This is a real newbie question, but it has me a bit stuck...
>I have a large number of text files in this format...
>Line 1: ID number
>Line 2: email addy
>Line 3: website url
>The files are named as the username, eg bob.user.
>What I want to do is sort the files by the id number so I can load the info
>into a mysql db, which obviously involves looping through all the files and
>checking the id number on the first line. I've been messing with this for a
>while now and can't seem to get it right.
>Any help very welcome, and thanks.
>
>Steve
>
>
>--
>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
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz
ICQ: 2808 2505