function [runnames,rundata,wvl]=importspectro(fname,makeplot)
% This function reads in a spectrum csv file and outputs the data
% Inputs:
% fname = filename of spectro csv
% makeplot = 1 or 0 whether user wants an immediate plot of all data
% Outputs:
% runnames = cell array has title of each run
% wvl = wavelengths measured
% rundata = matrix size(wvl,runnames) includes all data
%
% ENA 7/10/13

bdata=importdata(fname);
dataruns=bdata.textdata{1,1};
runnamecell=textscan(dataruns,'%s','Delimiter',',','MultipleDelimsAsOne',1);
runnames=runnamecell{1};
wvl=bdata.data(:,1);
rundata=zeros(length(wvl),length(runnames));
for i=1:length(runnames)
    rundata(:,i)=bdata.data(:,i.*2);
end

if makeplot==1
    figure;
    hold on
    legendinput='';
    for i=1:length(runnames)
        plot(wvl,rundata(:,i));
    end
    for i=1:length(runnames)-1
        legendinput=[legendinput,runnames{i},','];
    end
    legendinput=[legendinput,runnames{end}];
    legend(legendinput)
    xlabel('\lambda')
    ylabel('Absorbance (A)')
end