troubleshooting Question

change column header name when fetching .csv file via ftp

Avatar of Zac
ZacFlag for United Kingdom of Great Britain and Northern Ireland asked on
PHPNetworking Protocols
26 Comments2 Solutions400 ViewsLast Modified:
i'm fetching a csv file via ftp using the code below.

does anyone know if it would be possible to change the columns heading in the csv file at the same time as saving this csv file to my server?

so something like

column 1 = my columns name1
column 2 = my columns name2
column 3 = my columns name2

if this is possible could someone please give exampls of how in code please. thanks
zac

<?php 
                // define some variables 
        $folder_path = "C:/Inetpub/Www_root/shop/temp/";  
        $local_file = "file.csv"; 
        $server_file = "file.csv"; 
         
        //-- Connection Settings 
        $ftp_server = "ftp.server.co.uk"; // Address of FTP server. 
        $ftp_user_name = "user"; // Username 
        $ftp_user_pass = "name"; // Password 
        #$destination_file = "FILEPATH";  
         
        // set up basic connection 
        $conn_id = ftp_connect($ftp_server); 
         
        // login with username and password 
        $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 
         
        // try to download $server_file and save to $local_file 
        if (ftp_get($conn_id, $folder_path . $local_file, $server_file, FTP_BINARY)) { 
            echo "Successfully written to $local_file\n"; 
        } else { 
            echo "There was a problem\n"; 
        } 
         
        // close the connection 
        ftp_close($conn_id); 
?>
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 26 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 26 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros