Search code examples
excelcsvfileexcel-2013separator

Opening CSV file


I am generating CSV files. My first row it is column names, and it looks like

User ID;First Name;Last Name;Email;...

But if I will change User ID to ID, MS office cannot open this CSV and shows me error

Cannot read record(number of record)

But this file opens correctly on, Notepad++. I am using Excel 2013. Any ideas what is wrong?


Solution

  • You can solve the problem by inserting the following simple text at the beginning (the first line) of your .csv file:

    sep=;
    

    This will not be seen when the file is opened in Excel. What it will do - it will explicitly tell Excel that the delimiter is ;, and values will be separated into separate cells. Also, you will be able to use ID as the title of a column. Unfortunately, I cannot answer why Excel does not like it when you use this title at the beginning of the file.