Get variable value from imported text
이전 댓글 표시
Hello, I want to make database from the data inside my files
Here is the example of the data inside the file:

let's say I want to import the years, month, day (2020 10 3) in the first row of the data using importdata function to a matrix structure. The imported matrix is 10x1 cell in which 1 cell contains the string in 1 row. How to take just 2020 in first row string and store it in years, 10 in month, etc in the structure?
And another question, there is a table in the bottom of the data, at the example the header is in line 7. The header may be different for each file data, it may be in line 8 or 9. Is there any way to detect the header and import the data below it as a matrix structure?
edit here is attached the input data and the output example that I want
Here is the code that I tried to build:
St=struct('years',0.0,'month',0.0,'day',0.0, ...
'hours',0.0,'min',0.0,'sec',0.0);
files=dir('*-*');
N=length(files);
for i=1:N
file=files(i).name;
S=importdata(file);
St.years=S{1,1};
St.month=S{1,1};
St.day=S{1,1};
end
댓글 수: 3
dpb
2021년 3월 20일
Attach data file or at least a text file or code section of data, not images. Nothing can be done with them
Image Analyst
2021년 3월 20일
No idea without the data. What do you want and want do you not want (want to ignore)? Anonymize it with generic data if you think it's too secret to post. Otherwise probably no one can help.
theo
2021년 3월 20일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!