0

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.

Roshan
  • 521
  • 4
  • 16
  • 1
    The csv file actually uses the \r\n to delimit the lines within the file. Your import routine should honor this format as well. –  Nov 20 '13 at 21:06

1 Answers1

0

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);
Roshan
  • 521
  • 4
  • 16