【发布时间】:2013-04-20 19:49:22
【问题描述】:
我有一个基本的 csv 文件读取,但它无法读取保存在 Mac 平台上的 csv。
我知道问题来自Different operating system families have different line-ending conventions,但我无法解决。
我找到了一个建议 - 以二进制模式打开文件,但没有用。
代码非常基本:
file opening:
$this->fileHandler = fopen($this->filename, 'rb');
read line:
$columns = fgetcsv(
$this->fileHandler,
$this->length,
$this->delimiter,
$this->enclosure
);
我用 Notepad++ 打开了这两个文件,Mac 文件似乎在行尾缺少 \n 字符,但 \r 在那里。
【问题讨论】: