Import files from a folder into Matlab and create a file list

3 ビュー (過去 30 日間)
Susan
Susan 2020 年 3 月 30 日
コメント済み: Susan 2020 年 3 月 31 日
Greetings. I face problem in extracting more than 1000 .json files from a folder into Matlab. I would like to create a filelist containing all the files in the folder and then go through each files and extract data from them, something like
filelist = {'d90f3c.json', '112.json', ..., 'acd.json' }
for i=1:length(filelist)
vals{i} = jsondecode(fileread(filelist{i}));
% Do some operations
end
Is there any way that I can have the "filelist" rather than making filelist by copying and pasting the name of each file from the folder which seems takes forever?
Thanks in advance!

採用された回答

dpb
dpb 2020 年 3 月 30 日
d=dir('*.json');
for i=1:numel(d)
vals{i} = jsondecode(fileread(d(i).name));
...

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeJSON Format についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by