On Mon, 2008-10-13 at 15:02 -0700, bruce wrote:
> hi...
> 
> as a test... using the cli php... try to write a short app to read a file 
> that simulates your input csv file, and then writes it out as well...
> 
> once you do this, you'll know you have the logic to read/write/manipulate the 
> csv file.
> 
> after you can do this, go ahead and then create/work with a app to read a csv 
> file from the user/input/form data from a test website.
> 
> finally, after you're sure of your ability to manipulate the csv file 
> (read/write) than create the mysql process to insert the data..
> 
> you'll get it in no time...
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 13, 2008 2:56 PM
> To: php-general@lists.php.net
> Subject: [PHP] Csv issue
> 
> 
> I am using a form to select a csv file and then import it into mysql and 
> maybe im just drawling a blank here. But why is it blowing up.
> This thing loads like 14 million records into the database and I am clue less 
> how it can do that with a 2 record csv file.
> 
> <form enctype='multipart/form-data' action=? method=post>
> Upload:<input type=file name=filename>
> <input type=submit value='Upload'></form>
> 
> 
> $row = 1;
> $filename = $_POST['filename'];
> $handle = fopen("$filename", "r");
> while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
> {
> $num = count($data);
> echo "<p> $num fields in line $row: <br /></p>\n";
> $row++;
> }
> fclose($handle);
> print "Import done";
> 
> This will produce millions of lines until i go in and stop the process on the 
> server. I know its stupid but im drawling a blank as to why its doing this. 
> The csv file has 2 lines in period. 
> <p> 0 fields in line 1: <br /></p>
> <p> 0 fields in line 2: <br /></p>
> ect for millions of records.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
I had this happen when trying to read in a binary file as a CSV. Are you
sure that the file is a CSV, and if so, is it delimited in the way you
expect? 


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to