function SpecpHData = readspecpH(filename)
%SPECPH_PARSER input is a txt file generated by labview based on the
%Spectophotometric pH sampling method
data = readtable(filename);
try
    tbl = data(:,["Var1","Var2","Var2","Var46",...
        "Var49","Var42"]); % Var2 is time specto...
    % was used to process sample. Var2 is used again and replaced with...
    % DateTime the time the sample was collected.
catch
    tbl = data(:,{'Comments','DateTime','DateTime','Salinity','pH_tot','Temp_Samp'});
end
tbl.Properties.VariableNames = {'Flag','DateTimeRan','DateTime',...
    'Salinity','pH_tot','Temp_samp'}; % Rename the variables
QC = ~ismember(tbl.Flag,'junk'); % logical array of good measurements
% Parse out sample time from 'flag' and convert to datetime type
% This could be simplified probably with the QC logical array

tbl = tbl(QC,:);

datetimestr = strsplit(string(tbl.Flag),'_'); % part 2 is timestamp of sample
tbl.DateTime = datetime(datetimestr(2),InputFormat='uuuuMMdd');

tbl.DateTime.TimeZone = "UTC";

SpecpHData = tbl;

end

