ds = tabularTextDatastore('Tables for AI (9-23)\FTIR Prototypes\Prototype I_Commercial FTIR Data\Unknown (.txt)\pre_OpenSpecy\*.txt');
l_files = length(ds.Files);

reset(ds)
counter = 0;

% lable = [5 6 7 8 10 17]; %Only for proper labeling, otherwise, use i

for i = 1:l_files
    ndata = table2array(ds.read);
    T = [ndata(:,1), rescale(ndata(:,2))]; %Second column was ndata(:,2) / Changed for conversion/rescale
    header = {'wavelength' 'intensity'};
    Tf = [header; num2cell(T)];
    filename =  ['Unk_proc_', num2str(lable(i)),'.csv']; % second entry was num2str(i) for y in abs
    writecell(Tf,filename)
    counter = counter + 1
end

