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

1 回表示 (過去 30 日間)
UWM
UWM 2020 年 9 月 14 日
回答済み: Rik 2020 年 9 月 14 日
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?

採用された回答

Rik
Rik 2020 年 9 月 14 日
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{:});

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by