function [time, B_H, B_D, Qual, siteData] = importCARISMAICM(filename)
%IMPORTFILE Import numeric data from a text file as column vectors.
% Example:
%   [t,H,D,Q] = importCARISMAICM('20090824DAWS.ICM20',1, 1728000);

fileID = fopen(filename);

headerLine = fgetl(fileID);
C = textscan(headerLine,'%s %s %s %f %f %s %s %s %d %s');

if (strcmp(C{1},'#'))
    siteData = struct('siteID', C{2}, 'geoLat', C{4}, 'geoLon',C{5}, 'coilA', C{6}, 'coilB', C{7}, 'unit', C{8}, 'Fs',double(C{9}) );
    
    dateString  = char(C{3});
    year        = str2double(dateString(1:4));
    month       = str2double(dateString(5:6));
    day         = str2double(dateString(7:8));
    
    tempData    = textscan(fileID,'%2f%2f%6.3f %f %f %s\n');
    
    time = datetime(year, month, day, tempData{1,1}, tempData{1,2}, tempData{1,3});
    B_H         = tempData{4};
    B_D         = tempData{5};
    Qual        = tempData{6};
    
else
    fprintf('Failed to parse header. Terminating.\n');
end

fclose(fileID);


end