Reputation: 531
I am current writing a script in php that read a .csv file and push every entry to the database.
The .csv file has rows that ends with ','
a,b,c,d,e,v,f,
r,t,y,u,i,o,e,
when i use fgetcsv($handle, 1000, ",") to read the row, the entire content of the file is read as a single row (a,b,c,d,e,v,f,r,t,y,u,i,o,e,) how can i prevent this.
Upvotes: 0
Views: 1065
Reputation: 531
The reason was that the new line character was "MAC CR" character which was not recognized by php, to solve this issue i used
<?php
ini_set("auto_detect_line_endings", true);
Upvotes: 0