Re: [PHP] Export/Write rows from DBF to CSV

[email protected] (Andrew Ballard)
Newsgroups php.general
Message-ID <[email protected]>
On Thu, Feb 18, 2010 at 5:31 PM, OBXer <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.