function A = importfile_TSG(filename)
%IMPORTFILE Import data from a text file
%  SBE384599920260120053930 = IMPORTFILE(FILENAME) reads data from text
%  file FILENAME for the default selection.  Returns the data as a table.
%
%  SBE384599920260120053930 = 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:
%  SBE384599920260120053930 = importfile("/Volumes/Boss_SSD/Perseverance/raw/SBE3845999/SBE3845999_20260120_053930.csv", [2, Inf]);
%
%  See also READTABLE.
%
% Auto-generated by MATLAB on 26-Jan-2026 22:01:52

%% Input handling

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

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

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

% Specify column names and types
opts.VariableNames = ["dt", "lat", "lon", "temp_cal", "cond", "sss", "sv", "sst"];
opts.VariableTypes = ["string", "double", "double", "double", "double", "double", "double", "double"];

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

% Specify variable properties
opts = setvaropts(opts, "dt", "WhitespaceRule", "preserve");
opts = setvaropts(opts, "dt", "EmptyFieldRule", "auto");

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

end