import text file using importdata
古いコメントを表示
Hello everyone,
When I try to import text files with experiment infomation using importdata, it seems to only import a couple of lines from the .text file.
I use the following code that looks for the (attached) readme file
data_folder=dir(data_path); %data_path opens a participants folder with mulitple files including the readme file
for log=1:length(data_folder)
if endsWith( data_folder(log).name , 'README.txt' )
logfile_1 = importdata([data_path data_folder(log).name]);
end
end
Instead of loading the whole file I get the attached logfile_1 file. Where if you open the logfile_1.textdata we only have 3 rows and those are not complete. When googling solutions to loading .txt files this is I believe the way to go. I have tried loading it as a table, but that messes too much with the structure.
Does anyone have any idea why this happens and how I can force it to import the whole file?
Thank you for your time,
Douwe
採用された回答
その他の回答 (1 件)
This is a custom file format that simple generic readers can't handle. You'll have to write your own reader function for this type of file.
allLines = readlines('1111 F.A.S.T. Response Task 0-00-0000 README.txt')
Then have a loop where you check for certain words in each line (might use contains for that) , and then parse the found line to extract the particular words or numbers you want.
3 件のコメント
Douwe Horsthuis
2022 年 8 月 30 日
Image Analyst
2022 年 8 月 30 日
OK, glad it works for you. But how did the answer you accepted instead actually parse out all the stuff for you? You said that "works like a dream" but, to me, it looks like it merely just sucks up the whole file into a single character array and not giving you things like Age.
Douwe Horsthuis
2022 年 8 月 30 日
カテゴリ
ヘルプ センター および File Exchange で Scripts についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!