Posted by Chung Leong on 01/27/06 03:13
Eric Anderson wrote:
> I have some files that sit on a FTP server. These files contain data
> stored in a tab-separated format. I need to download these files and
> insert/update them in a MySQL database. My current basic strategy is to
> do the following:
>
> 1) Login to the ftp server using the FTP library in PHP
> 2) Create a variable that acts like a file handle using Stream_Var in PEAR.
> 3) Use ftp_fget() to read a remote file into this variable (this is so I
> don't have to write it to disk).
> 4) Parse that data now stored in memory using fgetcsv() (again treating
> that variable as a file handle using Stream_Var). This produces an array.
> 4) Insert/Update the data in the array using DB in PEAR.
Is there a reason why you can't use the built-in FTP stream wrapper?
[Back to original message]
|