Q. When and why should you suppress the EOL translation in csv file handling?

 

Answer :-


If you create a csv file on one operating system and use it on another. The EOL of one operating system will not be treated as EOL on another operating system. Also, if you have given a character, say '\r', in your text string (not as EOL but as part of a text string) and if you try to open and read from this file on a Macintosh system, what would happen? Mac OS will treat every '\r' as EOL - yes, including the one you gave as part of the text string.


So what is the solution? Well, the solution is pretty simple. Just suppress the EOL translation by specify third argument of open() as newline = (null string - no space in quotes).

If you specify the newline argument while writing onto a csv file, it will create a csv file with no EOL translation and you will be able to use csv file in normal way on any platform.

6 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post