Change line feed of csv file to the same one

I need to work with csv files. I want to write an web app which is working with csv files and is written in php.
Problem is all the csv files have diffrent line feeds /r, /n,/r/n/.
I need to have the same in all of them.
Till now i do it like this:

exec("sed -i 's/\r$//' files/uploads/$fileName"); // DOS to Unix
exec("sed -i 's/$/\r/' files/uploads/$fileName"); // Unix to DOS

And in the end all of them have /r/n.
But what if i get a csv file with /r as line feed, how to deal with that?

Thanks for your help

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s