MATLAB Answers

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

4 views (last 30 days)
Susanna
Susanna on 30 Mar 2020
Commented: Susanna on 31 Mar 2020
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!

  0 Comments

Sign in to comment.

Accepted Answer

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

More Answers (0)

Sign in to answer this question.

Tags


Translated by