Search code examples
pythonpandasexcelcsvxlsx

What is the difference between Excel and CSV?


I am learning about Python. I am trying to store project data to a .CSV file using Pandas library.

I know csv is comma separated values, the data is separated by comma(,). I am wondering why I would use a .CSV instead of the other Excel file types?


Solution

  • The major differences between Excel XLSX and CSV file format are the file size and the formatting.

    In a *.CSV file, the file size is smaller, and the data looks like this:
    (there is no formatting, just raw data)
    enter image description here

    And if you open using a text editor, you'd get this:

    idx,col1,col2
    123,aaa,xxx
    456,bbb,yyy
    789,ccc,zzz
    

    And in a *.XLSX file, the file size is larger, and the data looks like this:
    (this format allows formatting such as tables, borders, background color, bold, etc)
    enter image description here

    And if you open with a text editor, you'd get this:

    PK     ! A7傁n     [Content_Types].xml ?(?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 琓蒼?絎?D綱墶嚜??[$?榵扻$跺(鼄'fQU??Ql蟍&?&YB@鉲.鶼O$`璻?鼿烢偆琕嵆悑5?
    镲拥 L岗b.j""%5?3缌騈锽珗?C%?妾?陕YK)ub8x僐-J轜技Q23V$瘺sU.旝?盤勾?I晔?燷県:C@i?╩23???g€/#莺矢2
    泌x|`隚簼惝秛_?傃悓U燨詹w筳鋸髾s箪4去瓑-蔤e霳?e|鮫,ん佅??愸y絼s?i? 藓??s??耵V7?麛幵88彍? 梬a懏:??霤rh伥??轁鄸??   PK     ! 礥0#?   L   _rels/.rels ?(?     
    <truncated>
    

    Generally, I use CSV format to store raw data, and use XLSX format to present the data.