<?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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to