Effacer les filtres
Effacer les filtres

Please I want to know how to delete the first line of a file text with matlab ?

2 vues (au cours des 30 derniers jours)
Please help me ! thank you

Réponse acceptée

Walter Roberson
Walter Roberson le 12 Mai 2016
One way is to fopen the file for reading, fopen a different file for writing, fgetl the first line of the input and throw it away. Now fread the rest of the input and fwrite to the output. fclose both. Rename the output file to the input name.
There are other ways, but there is no direct way to delete a line: they all come down to copying input to output leaving out the part you do not want.
  6 commentaires
Walter Roberson
Walter Roberson le 12 Mai 2016
movefile('NewFile.txt', 'ExistingFile.txt');
ubaid haroon
ubaid haroon le 20 Oct 2017
Very neat. I was able to use this piece of code

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Low-Level File I/O dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by