フィルターのクリア

about import .txt file,how to change special character in its name

1 回表示 (過去 30 日間)
Roger
Roger 2014 年 2 月 13 日
編集済み: Azzi Abdelmalek 2014 年 2 月 13 日
like Chande.2008052716-17hZCFPF.GY.txt after importing , then the variable name change to Chande_2008052716_17hZCFPF_GY, how to make it,thanks
what i need is deleting the last .txt and changing special symbols like .and - to _, just change the string

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 13 日
編集済み: Azzi Abdelmalek 2014 年 2 月 13 日
s='Chande.2008052716-17hZCFPF.GY.txt'
s1=strrep(s,'.','_')
s1=strrep(s1,'-','_')
%or
s='Chande.2008052716-17hZCFPF.GY.txt'
s1=regexprep(s,'[-\.]+','_')
  3 件のコメント
Roger
Roger 2014 年 2 月 13 日
i have a idea ,thanks
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 13 日
編集済み: Azzi Abdelmalek 2014 年 2 月 13 日
You can remove .txt by
s='Chande.2008052716-17hZCFPF.GY.txt'
s1=regexprep(s,'[-\.]+','_')
s1(end-3:end)=[]

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 2 月 13 日
Change how you do the importing.
What is the format of the file? Are there header lines?

カテゴリ

Help Center および File ExchangeMuPAD についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by