Search code examples
excelcsvimportquotespartial

Excel stops import of CSV file when reaching quotes


The csv file when opened in notepad looks like:

Name,Jun 13,Jun 20,Jun 27,Jul 4,Jul 11,Jul 18,Jul 25,Aug 1,Aug 8,Aug 15
LastName"," FirstName,40,40,0,8,0,0,0,8,0,0
LastName"," FirstName,32,40,40,20,12,12,12,8,0,0
LastName"," FirstName,40,40,40,48,40,40,40,40,24,0

However, when opening in excel it cuts off at the first quotation mark and stops the import. In excel it looks like:

Name,Jun 13,Jun 20,Jun 27,Jul 4,Jul 11,Jul 18,Jul 25,Aug 1,Aug 8,Aug 15
LastName"

My understanding is that when you want to have a comma escaped in CSV, you surround it with double quotes, which I did because I want the first name and last name to be in the same cell. I don't want to change anything to the local excel settings because this will be a file that will be downloaded from a website, so having every user change settings would not be ideal.

Thanks!


Solution

  • Change it to:

    Name,Jun 13,Jun 20,Jun 27,Jul 4,Jul 11,Jul 18,Jul 25,Aug 1,Aug 8,Aug 15
    "LastName, FirstName",40,40,0,8,0,0,0,8,0,0
    "LastName, FirstName",32,40,40,20,12,12,12,8,0,0
    "LastName, FirstName",40,40,40,48,40,40,40,40,24,0
    

    Here is a spec on how to handle different characters in CSV format:

    https://www.rfc-editor.org/rfc/rfc4180