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

조회 수: 3 (최근 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 CenterFile Exchange에서 MuPAD에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by