Question

I'm importing a CSV from DB2 into MySQL, all goes well until half a million rows in I encounter \" from a column with encrypted data.

Here is an example:

100,"foo","bar","µ┬;¬µ┬;→ºµ┬;Öì\"
101,"foo","bar","$⌠ù¶∙$∙µ┬µ┬;→ºµ┬;Öì"

When fgetcsv parses this, it escapes the last double quote and includes the next line as if it is part of that field.

I see a few bug reports and in PHP 5.3 they added an escape param for fgetcsv.

What does DB2 use as an escape? Just "?

Was it helpful?

Solution

From the comments on the fgetcsv manual page it looks like this is a fairly common issue with no real good workaround. There are however some alternate functions which people have been kind enough to post on the page which might do what you need.

Here is a link to one of them: http://us3.php.net/manual/en/function.fgetcsv.php#98800

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top