2%> This is the base
class for generating objects
3%> that contain the **tabular contents** of a given file.
6%> This
class is meant to be primarily internally used
7%> by the ParaMonte library routines (e.g., samplers).
9%> Tabular file comprises a header line followed by a table of data.<br>
10%> If there are more than one header line, only the last such line is
11%> considered as header and the rest are discarded as text.<br>
14%> See the documentation of the
class constructor.<br>
17%> See below
for information on the attributes (properties).
20%> See below
for information on the methods.
25%> \JoshuaOsborne, May 21 2024, 6:08 PM, University of Texas at Arlington<br>
26%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
27%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
30 properties(Access =
public)
34 %> The scalar MATLAB
string representing
35 %> the field separator used in the file.<br>
36 %> This
property is either specified by
37 %> the user or is inferred from the
38 %> file to be read.<br>
44 %> The scalar MATLAB integer representing
45 %> the number of columns identified in the file.<br>
51 %> The scalar MATLAB integer representing
52 %> the number of rows identified in the file.<br>
58 %> The scalar MATLAB ``table`` containing the
59 %> contents of the file as a dataframe.<br>
64 methods(Access =
public)
67 %> Construct and
return a scalar
object of
class [pm.io.FileContentsTabular](@ref
FileContentsTabular).
70 %> This is the constructor of the
class [pm.io.FileContentsTabular](@ref
FileContentsTabular).
72 %> \param[in] file : See the documentation of the corresponding argument of [pm.io.FileContents](@ref
FileContents).
73 %> \param[in] silent : See the documentation of the corresponding argument of [pm.io.FileContents](@ref
FileContents).
74 %> \param[in] sep : The input scalar MATLAB
string containing the field separator used in the file.<br>
75 %> Use ``
"\t"`` to represent the horizontal
tab character.<br>
76 %> (**optional**. The
default is inferred from the contents of the specified input ``file``.)
79 %> ``self`` : The output scalar
object of
class [pm.io.FileContentsTabular](@ref
FileContentsTabular).
85 %> contents = pm.io.FileContentsTabular(file, [])
86 %> contents = pm.io.FileContentsTabular(file, silent)
87 %> contents = pm.io.FileContentsTabular(file, [], [])
88 %> contents = pm.io.FileContentsTabular(file, [], sep)
89 %> contents = pm.io.FileContentsTabular(file, silent, [])
90 %> contents = pm.io.FileContentsTabular(file, silent, sep)
97 %> \JoshuaOsborne, May 21 2024, 6:11 PM, University of Texas at Arlington<br>
98 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
99 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
110 if pm.array.len(sep) == 0
115 self = self@pm.io.FileContents(file, silent);
116 if ~isfile(self.file)
118 + "The specified input file:" + newline ...
120 + pm.io.
tab + """" + self.file + """" + newline ...
122 + "does not exist." + newline ...
126 if pm.array.
len(sep) == 0
127 [d, self.sep, ~] = importdata(self.file);
128 self.sep =
string(self.sep);
129 elseif length(convertStringsToChars(sep)) == 1 || strcmpi(sep, "\t")
130 [d, self.sep, ~] = importdata(self.file, convertStringsToChars(sep));
131 self.sep =
string(self.sep);
135 + "Multicharacter separators are unsupported as of ParaMonte 2." + newline ...
136 + "You have specified sep = """ + sep + """." + newline ...
137 + "If this feature is desired, please report this request at:" + newline ...
145 + "The specified input file is empty:" + newline ...
147 + pm.io.
tab + self.file + newline ...
150 elseif ~isfield(d, "colheaders") || ~isfield(d, "data")
152 + "The specified input file is not a table:" + newline ...
154 + pm.io.
tab + self.file + newline ...
156 + "The default or the inferred choice of field separator (""" + sep + """) may be incorrect." + newline ...
157 + "Alternatively, the specified file contents may be corrupted and non-tabular." + newline ...
158 + "If the specified tile path is a
weblink, ensure the
weblink corrently points" + newline ...
159 + "to the target raw tabular ASCII file and not an HTML page." + newline ...
163 self.ncol = size(d.data, 2);
164 self.nrow = size(d.data, 1);
165 self.df = array2table(d.data, 'VariableNames', d.colheaders);
168 disp("ncol = " +
string(self.ncol) + ", nrow = " +
string(self.nrow));
This is the base class for generating objects that contain the tabular contents of a given file.
function FileContentsTabular(in file, in silent, in sep)
Construct and return a scalar object of class pm.io.FileContentsTabular.
This is the base class for generating objects that contain the contents of a given file.
function href(in url)
Return an HTML-style decoration of the input URL if the ParaMonte MATLAB library is used in GUI,...
function len(in obj)
Return a scalar MATLAB whole-number containing the length of the input scalar or vector object.
function lib()
Return a scalar MATLAB string containing the path to the lib directory of the ParaMonte library packa...
function tab()
Return a scalar MATLAB string containing 4 blank characters equivalent to a tab character.
function weblink(in silent)
Return a scalar MATLAB string containing the download weblink to latest ParaMonte MATLAB library vers...
function weblinks()
Return a structure containing tree of weblinks for the ParaMonte MATLAB library source file and docum...