1

I have next problem: when I save a line into my csv file, I use

fputcsv($this->_streamHandler, $row, $delimiter, $enclosure);

where:

$enclosure = '"'
$delimite= "#";
$row = array("somemail@gmail.com", "someName", "2014-01-29 10:13:35");

So, after this I have next line in my file:

somemail@gmail.com#someName#"2014-01-29 10:13:35"

Why date element (2014-01-29 10:13:35) saved with quotes to file?

If I set $enclosure = '', fputcsv return false, if I set another symbol, for example"-", it wil save line with '-' at the beginning of each element.

sergio
  • 5,210
  • 7
  • 24
  • 46

1 Answers1

1

Why are you providing a delimiter or an enclosure? You are telling it separate your fields using #. Remove the two optional arguments. They are for overiding the delimiter and enclosure characters.

     fputcsv($this->_streamHandler, $row);

http://us2.php.net/manual/en/function.fputcsv.php

If your date is already quoted, you need to remove any prexisting quotes:

    $row[2] = str_replace('"', '', $row[2]);

Look here for a similar SO question: Avoid default quotes from csv file when using fputcsv

Community
  • 1
  • 1