Re: CSV file
| From: | Richard Heyes | Date: | Wed, 24 Jun 2009 14:12:45 +0000 |
| Subject: | Re: CSV file | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-294523@lists.php.net to get a copy of this message | ||
Hi,
> You can read the whole file (file_get_contents) and count the number
> of "\n" in it, or read it line by line with fgets and store the lines
> in an array, and then the number of lines is the count() of the array,
> and you can use that array to store it in the database.
If you have a billion line CSV then speed may suffer somewhat though.
Best to still use fgets() or fgetcsv() and count as you go.
--
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net - updated 20th June)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)
PHP SMTP: http://www.phpguru.org/smtp