delete data of csv file
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SINDU GOKULAPATI
el 24 de Mzo. de 2021
Editada: SINDU GOKULAPATI
el 16 de Mayo de 2021
i have created a code such that data is appended to csv file every time the loop runs
but when i run the program again the new data is added with the old one
but i want to clear out the data in then csvfile before hand
what command do i use
delete('xyz.csv') deletes the whole file
4 comentarios
Merve Buyukbas
el 24 de Mzo. de 2021
But you shouldn't count on the main directory and instead use full paths everywhere in your script. This way the data can be located anywhere independently on where the code is.

Respuesta aceptada
Walter Roberson
el 24 de Mzo. de 2021
fclose(fopen('xyz.csv', 'w'));
When you open a file for writing with 'w' access, the existing content is discarded.
Note: the POSIX standard library specifies truncate() and ftruncate() functions that would be a closer match. However, MATLAB does not implement either of those.
6 comentarios
Walter Roberson
el 12 de Mayo de 2021
csvread() calls dlmread() with delimiter ','
You are writing to a file that is not necesarily in the same place as you are reading from, as your current directory is not necessarily D:\sem6\PROJECT
SINDU GOKULAPATI
el 16 de Mayo de 2021
Editada: SINDU GOKULAPATI
el 16 de Mayo de 2021
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!