Azzera filtri
Azzera filtri

Remove line from text file if in the first column there is a certain character

1 visualizzazione (ultimi 30 giorni)
Hi,
I have a .txt file with many rows. Short example:
$GN,074043.00,11,09,2020,00,00*
2 -0000,00 00000,00 $GN,
3 00005,00 00092,00 $GN,
4 00045,00 00042,00 $GN,
5 00005,00 00092,00 $GN,
6 00035,00 00047,00 $GN,
$GN,074136.00,11,09,2020,00,00*
7 00005,00 00092,00 $GN,
8 00025,00 00051,99 $GN,
9 00005,00 00092,00 $GN,
$GN,074152.00,11,09,2020,00,00*
10 00015,00 00056,99 $GN,
11 00005,00 00092,00 $GN,
12 00005,00 00062,01 $GN,
...
I wont to remove all lines which starting with "$" (in first column).
How can it be done?

Risposta accettata

Rik
Rik il 14 Set 2020
Split the lines to cells and use a loop (or cellfun) to remove all elements where strcmp(contents(1),'$') is true. Then you can print the cell array to your file with
fprintf(fid,'%s\n',data{:});

Più risposte (0)

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by