matlabmatlab-table

writetable without dimension names


I'm trying to write a CSV from a table using writetable with writetable(..., 'WriteRowNames', true), but when I do so, Matlab defaults to putting Row in the (1,1) cell of the CSV. I know I can change Row to another string by setting myTable.Properties.DimensionNames{1} but I can't set that to be blank and so it seems like I'm forced to have some text in that (1,1) cell.

Is there a way to leave the (1,1) element of my CSV blank and still write the row names?


Solution

  • There doesn't appear to be any way to set any of the character arrays in the 'DimensionNames' field to either empty or whitespace. One option is to create your .csv file as you do above, then use xlswrite to clear that first cell:

    xlswrite('your_file.csv', {''}, 1, 'A1');
    

    Even though the xlswrite documentation states that the file argument should be a .xls, it still works properly for me.