function ag = rd_ag(filename, dataLines)
%IMPORTFILE Import data from a text file
%  ACPL10CMTARA23001Z00DOM1 = IMPORTFILE(FILENAME) reads data from text
%  file FILENAME for the default selection.  Returns the data as a table.
%
%  ACPL10CMTARA23001Z00DOM1 = IMPORTFILE(FILE, DATALINES) reads data for
%  the specified row interval(s) of text file FILENAME. Specify
%  DATALINES as a positive scalar integer or a N-by-2 array of positive
%  scalar integers for dis-contiguous row intervals.
%
%  Example:
%  acpL10cmTARA23001Z00DOM1 = importfile("/Volumes/Data2/TaraEuropa/Partner_data/CNR-P/Absorption spectra/_ac_pL_10cm_TARA23_001_Z00_DOM-1.txt", [1, Inf]);
%
%  See also READTABLE.
%
% Auto-generated by MATLAB on 17-Feb-2024 15:07:38

%% Input handling

% If dataLines is not specified, define defaults
if nargin < 2
    dataLines = [1, Inf];
end

%% Set up the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 2);

% Specify range and delimiter
opts.DataLines = dataLines;
opts.Delimiter = "\t";

% Specify column names and types
opts.VariableNames = ["wl", "spec"];
opts.VariableTypes = ["double", "double"];

% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";

% Import the data
ag = readtable(filename, opts);

end