Re: MySQL: copying entire columns
| From: | Andrey Hristov | Date: | Fri, 30 Nov 2001 13:24:31 +0000 |
| Subject: | Re: MySQL: copying entire columns | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-76197@lists.php.net to get a copy of this message | ||
<?php
$which_column = 0; // starting from 0
$fname = "some.csv";
$out_fname = "some_new.csv";
$cschar = ",";
$f_cont = file($fname);
foreach ($f_cont as $key =>$value){
$tmp = explode($cschar,trim($value));
$tmp[count($tmp)] = $tmp[$which_column];
unset($tmp[$which_column]);
$out_cont[] = implode(",",$tmp);
}
$fd = fopen($out_fname,'w+');
fwrite($fd,implode("\r\n",$out_cont));
fclose($fd);
?>
HTH
Regards,
Andrey Hristov
----- Original Message -----
From: "Tom Churm" <thomas.churm@pixelpark.com>
To: <php-general@lists.php.net>
Sent: Friday, November 30, 2001 2:53 PM
Subject: [PHP] MySQL: copying entire columns
> hi,
>
> i've created a mysql table from an excel csv dump and the field-order is
> not the way i want it. could someone possibly give me a hint on how i
> can create a copy of an entire column, place it in the position where i
> want in my table, and then delete the original column?
>
> i'm using phpMyAdmin and there doesn't appear to be any way to
> restructure my table--so i've gotta resort to sql.
>
> mucho gracias,
>
> tom
>
> --
> 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
>
>