Question

I am using a CsvReader to read a csv generated through a Cobol script that i can't access.

In my script i have this code

$file = new \SplFileObject('/path/to/my/Category_1396548812.csv');
$reader = new CsvReader($file, "~", chr(0));
var_dump($reader->count());

and it output

int(1)

The csv file contains 7 lines and it is available for download here: https://www.dropbox.com/s/ux9wgeofq4ejoj4/Category_1396548812.csv

If i create another csv from the scratch, it works properly and the method count() return the right number of rows, so i think the issue could be in the format of the generated csv, but i don't understand how to fix the problem.

Any suggestion?

Cheers

Was it helpful?

Solution

The problem was that the file generated use \r as line separator instead of a \n.

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