MATLAB: Are some fields in a CSV file created using FPRINTF in MATLAB 7.8 (R2009a) combined into one cell when the file is opened in Microsoft Excel

excelMATLABqualifiertext;

I am creating a CSV file using the FPRINTF function in MATLAB 7.8 (R2009a). The data I am writing and the code I am using to write the data are specified below:
c = { 'abc' 'def' '"ghi' 'jkl' '"mno' 'pqr' }
fp = fopen('test.csv', 'wt');
fprintf(fp, '%s,', c{1:end-1});
fprintf(fp, '%s\n', c{end});
fclose(fp);
When I open this file in Microsoft Excel, I expect cells A1 to A6 to be populated. However, only cells A1 to A4 are populated and the cell A3 contains the following value
ghi,jkl,mno

Best Answer

This behavior is a result of the import properties used by Microsoft Excel. The reason that the data
"ghi,jkl,"mno
is being grouped into one cell is because of the "Text Qualifier" used by Microsoft Excel to import data. The default Text Qualifier used by Excel is (").When Excel encounters the text qualifier character, all of the text that follows this character and precedes the next occurrence of the same character, it is imported as one value, even if the text contains a delimiter character.
You can specify this Text Qualifier to be {None} when importing the data into an Excel SpreadSheet. The steps below indicate how you can do this.
1. Launch Microsoft Excel and create a new Workbook.
2. Select Import Data from Text source.
2. Select the file test.csv. This will launch the Text Import Wizard.
5. Select Next on Step 1 of the Text Import Wizard.
6. In Step 2, under the Delimiter’s group, uncheck the box next to “Tab” and check the box next to “Comma”. Also select {None} from the Text Qualifier Drop Down menu.
7. Click Finish on Step 3 of the Text Import Wizard.