필터 지우기
필터 지우기

Create a string variable with a value same as the name of an imported csv file

조회 수: 1 (최근 30일)
Hi
After importing a csv file I see that a variable 'textdata' has been created. It is identified by curly brackets. In row 1, column 1 is the information I want. Here's an example:
This is the name of the CSV file:
C:\Program Files\BOSE\Etienne\Data files\WW series_block tests\WW11cRH_29May2012.TXT
I want to create a variable as follows:
SampleDescrip='WW11cRH-29May2012'
(Ideally I want to replace the underscore in the original name with a dash).
Thank you.

채택된 답변

Oleg Komarov
Oleg Komarov 2012년 5월 30일
regexprep('WW11cRH_29May2012.TXT','_','-')
EDIT
name = 'C:\Program Files\BOSE\Etienne\Data files\WW series_block tests\WW11cRH_29May2012.TXT';
[path,n] = fileparts(name);
SampleDescrip = regexprep(n,'_','-');
  댓글 수: 5

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by