clear;

% don't import excel files if the file has been imported already.
if (exist('IO_data.mat', 'file') ~= 2)
    count = 1;
    for year = 1997:2021
        [~, ~, raw] = xlsread('IOUse_Before_Redefinitions_PRO_1997-2021_Summary.xlsx',num2str(year),'C8:CR86');
        R = cellfun(@(x) ~isnumeric(x) && ~islogical(x),raw); % Find non-numeric cells
        raw(R) = {NaN}; % Replace non-numeric cells
        IO_matrix_sum(:,:,count)= reshape([raw{:}],size(raw));
        count = count+1;
    end
    [~, ~, indname] = xlsread('IOUse_Before_Redefinitions_PRO_1997-2021_Summary.xlsx','1997','B8:B86');
    indname(cellfun(@(x) ~isempty(x) && isnumeric(x) && isnan(x),indname)) = {''};

    clear ans count R raw year
    save IO_sum.mat
else
    load IO_sum.mat
end