PHP 5.3 fgetcsv \"
我正在将 CSV 从 DB2 导入 MySQL,一切都很顺利,直到我遇到来自加密数据列的 50 万行 \" 。
下面是一个示例:
100,"foo","bar","µ┬;¬µ┬;→ºµ┬;Öì\"
101,"foo","bar","$⌠ù¶∙$∙µ┬µ┬;→ºµ┬;Öì"
当 fgetcsv 解析此数据时,它会转义最后一个双引号并包含下一行,就好像它是该字段的一部分一样,
我看到了一些错误报告,并且在 PHP 5.3 中,他们添加了 fgetcsv 的转义参数。
DB2 使用什么作为转义?
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 "?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自
fgetcsv
手册的评论页面看起来这是一个相当常见的问题,没有真正好的解决方法。然而,人们已经在页面上发布了一些替代功能,这些功能可能可以满足您的需要。以下是其中之一的链接: https://www.php .net/manual/en/function.fgetcsv.php#98800
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: https://www.php.net/manual/en/function.fgetcsv.php#98800