function varData = gatherArchive(fileList, variableName)
    % GATHERARCHIVE Extracts a variable with a given name from a list of .h5 files
    %
    % Inputs:
    %   - fileList: A cell array of strings representing the file names or paths
    %               of the .h5 files to extract the variable from
    %   - variableName: A string representing the name of the variable to extract
    %
    % Output:
    %   - varData: A cell array of matrices representing the values of the
    %              variable in each of the .h5 files

    % Initialize the output variable
    varData = cell(length(fileList), 1);

    % Loop through each file in the list
    for i = 1:length(fileList)
        try
            % Try reading the variable directly
            varData{i} = h5read(fileList{i}, variableName);
        catch
            % Handle exceptions and try alternative approaches

            % Try reading with a different path if the original attempt failed
            try
                varData{i} = h5read(fileList{i}, ['/DataProducts/' variableName]);
            catch
                % If still unsuccessful, attempt reading from an ICARTT file
                try
                    [path, filename, ext] = fileparts(fileList{i});
                    ict_path = strrep(path, '/Archive','/mlh/');
                    ict_file = strcat(filename,'.ict');
                    full_path = strcat(ict_path,ict_file);
                    all_data = ICARTTreader(full_path);
                    mlh_data = all_data.MLH;
                    varData{i} = mlh_data;
                catch ex
                    % Display the error message
                    %disp(['Error reading file: ' fileList{i}]);
                    %disp(['Error message: ' ex.message]);
                end
            end
        end
    end
end








