Borrar filtros
Borrar filtros

How to overwrite my data everytime I run my code?

27 visualizaciones (últimos 30 días)
Abigail
Abigail el 13 de Ag. de 2024 a las 11:12
Respondida: Hassaan el 13 de Ag. de 2024 a las 11:28
I'm currently writing a program and everytime I run it, it just adds the data to the excel vs deleting the contents of the excel and replacing it with new data. I'm using the writetable function which I thought would automatically clear the excel before filling it with new data. Any ideas?

Respuesta aceptada

Hassaan
Hassaan el 13 de Ag. de 2024 a las 11:28
% Your data table
data = table(...); % Replace with your actual data
% Delete the existing file (if it exists)
if exist('your_file.xlsx', 'file')
delete('your_file.xlsx');
end
% Write the data to an Excel file and overwrite it
writetable(data, 'your_file.xlsx', 'WriteMode', 'overwrite');

Más respuestas (0)

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by