Borrar filtros
Borrar filtros

writetable adds unnecessary columns to Excel file

5 visualizaciones (últimos 30 días)
Thomas Kirsh
Thomas Kirsh el 6 de Ag. de 2020
Comentada: Thomas Kirsh el 7 de Ag. de 2020
I'm trying to save my table to an Excel spreadsheet.
test_limits = {'1', '2', '3'};
test_sens = {'0.54(0.02)', '0.89(0.01)', '0.34(0.01)'};
test_auc = {'0.78(0.04)', '0.91(0.02)', '0.64(0.02)'};
test_table = table(test_limits', test_sens', test_auc', 'VariableNames', {'Threshold', 'Sensitivity', 'AUC'});
writetable(test_table, 'test_table.xlsx')
However, when I open the file, the table is saved properly in the first 3 columns, but there are 6 more columns called "Sensitivity_1", "Sensitivity_2", "Sensitivity_3", "AUC_1", "AUC_2", "AUC_3" with the corresponding inputs in row format.
Why are these extra columns being added? I've tried transposing the variable name cell array but that doesn't change the results. I couldn't find any similar answers anywhere here.

Respuesta aceptada

Image Analyst
Image Analyst el 6 de Ag. de 2020
I see no such extra columns. Are you sure they're not still existing from a prior run where you forgot to transpose the variables while creating the table? It will just blast over cells, and any in there from a prior run will still be there. You might want to delete the workbook before you call writetable
fileName = 'test_table.xlsx';
if isfile(fileName)
delete(fileName);
end
writetable(test_table, fileName);
  1 comentario
Thomas Kirsh
Thomas Kirsh el 7 de Ag. de 2020
It seems that's what happened. After deleteing the files manually and running my code again, the extra columns don't appear. Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by