☞ CSV stands for Comma Separated Values.
☞ It is just like a text file i.e. in human readable form.
☞ It is extensively used to store tabular data, in a spreadsheet or database.
☞ The default delimiter is comma. Other delimiters are colon, semi-colon, tab etc.
☞ To work on CSV files, we need to import the csv module :- import csv.
☞ Advantages :
☞ On different OS, newline argument specifies how python handles new line characters while working with csv files.
Operating System | EOL characters |
---|---|
MAC | \r |
UNIX | \n |
MS DOS, WINDOWS | \r, \n |
NULL | \0 |
NOTE :- If you will not pass the newline argument in open(), then it will take the above mentioned EOL characters as a default value according to the OS.
☞ If you open this file on any other OS then it makes changes according to that and your file will behave unexpectedly. To overcome this, an additional optional argument as newline= ‘ ’ with file open() is used.