开发者

Is there a library that can write an RFC 4180 CSV file with PHP? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 6 years ago.

开发者_如何学JAVA Improve this question

I am aware of fputcsv, but according to this "wontfix" bug fputcsv does not correctly escape input, and its behavior will not be fixed for compatibility reasons. I would prefer an implementation that is compliant with RFC 4180 so Excel and LibreOffice can open it in all cases.

I've tried googling for a library that does this correctly, but there doesn't seem to be a consensus on a decent third party library, instead commonly suggesting the defective fputcsv. I could always roll my own, but I'd prefer not to reinvent the wheel if at all possible.


It seems that every library out there stopped development some time in 2008. I'm not sure what's up with that. Here seem to be the popular-ish options:

  • PEAR's File_CSV, with zero end-user documentation, as we've come to expect from PEAR. This looks like the expected configuration info, including those for separator and quote.
  • parseCSV seems sane enough
  • PHP CSV Utils is linked quite a bit, though the "new blog" hosting updates is long gone.

I can't vouch for any of these. I happen to live in a magical land where I only need to deal with Excel-generated CSV files that will never, ever contain newlines in a field. This lets me get away with fgetcsv/fputcsv and be blissfully ignorant of how they're broken in the real world.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜