ddeboer / data-import

Import data from and export data to a range of different file formats and media
MIT License
567 stars 123 forks source link

CSV reading problems #283

Closed ekaitzastiz closed 8 years ago

ekaitzastiz commented 8 years ago

Hello I use this package to import CSV, everything works like a charm when my csv is generated in a linux or MAC, but I have problems when it's generated in Windows. In other app, where I use php functions, no package, i had same problem, it was line jump o break and I solve it using \n and \r... and also things like quotes... Is the package prepared to import windows csv by default or do I need to configure something or pass some parameter, I only see that there is a parameter to set the delimiter... Thank you,

Baachi commented 8 years ago

Hey @ekaitzastiz the problem is that windows and linux/mac use different newline characters. The CsvWriter use the php function fputcsv so the problem is the same. The simplest solution is to made str_replace("\r", \r\n", $content).

ekaitzastiz commented 8 years ago

Yes, I know that is different, that was the reason I was asking, if there was any parameter, or if the only solution was to do in that way you've told me.

Thank you, nice work with the package, It helped me a lot!

iBasit commented 8 years ago

This is for future reference, you can use following ini settings to solve this problem

ini_set('auto_detect_line_endings', TRUE);