How can i extract information from filename in matlab and write into excel file?
Show older comments
Hi I want to read excel data file.
Read the file name from which i read the data. File name for example: 00_MOTEMG_Walk_25lb_09_18_2012.xls
Extract certain information from the FILENAME to ID,EXP, Protocol,Load and Date (Column of output excel sheet).
Write to an excel sheet ID (00),EXP(MOTEMG), Protocol(Walk),Load(25lb) and Date(09_18_2012), DATA from EXCEL FILE. Please help me out.
Answers (1)
Walter Roberson
on 5 Dec 2012
filename = '00_MOTEMG_Walk_25lb_09_18_2012.xls';
filename(find(filename == '.',1,'last'):end) = []; %remove extension
C = regexp(filename, '_', 'split');
ID = C{1}; EXP = C{2}; Protocol = C{3}; Load = C{4}; Date = [C{5} '_' C{6} '_' C{7}];
2 Comments
Ahmad Rusumdar
on 12 Dec 2016
Dear Walter, I have similar kind of problem. For instance a excel sheet in which i got the path of the file in second column (100 rows) e.g. C:\Users\usename\Desktop\Regression\myfile1.txt upto C:\Users\usename\Desktop\Regression\myfile100.txt How can i get the file name and save the file names in my matlab table?
it will be so much help if you can throw light on my problem.
Thanks in advance
Walter Roberson
on 12 Dec 2016
Use fileparts()
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!