Re: Export/Write rows from DBF to CSV

From: Date: Fri, 19 Feb 2010 14:56:34 +0000
Subject: Re: Export/Write rows from DBF to CSV
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-302202@lists.php.net to get a copy of this message
On Thu, Feb 18, 2010 at 5:31 PM, OBXer <dan@therealouterbanks.com> wrote: > > I'm trying to adopt this piece of code for my use.  I fixed the csv_data .= > trim error.  Does anyone know how I can fix empty fields?  Everything is > dumping to a csv file but information is not matching up.  I don't know if I > can insert a space or something if field is blank? > > If you're trying to write csv data, why not use fputcsv($_fp, $row) to write each line rather than concatenating all the lines into a single value and then writing that string to a file? It will correctly handle empty values (as long as the key is still present in the array) and I've found it to be much faster at writing larger data sets than trying to concatenate the CSV in code. http://www.php.net/manual/en/function.fputcsv.php Andrew

« previous php.general (#302202) next »