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)
32 %> sep : The scalar MATLAB
string representing
33 %> the field separator used in the file.<br>
34 %> This
property is either specified by
35 %> the user or is inferred from the
40 %> ncol : The scalar MATLAB integer representing
41 %> the number of columns identified in the file.
45 %> nrow : The scalar MATLAB integer representing
46 %> the number of rows identified in the file.
50 %> df : The scalar MATLAB table containing the
51 %> contents of the file as a dataframe.
56 methods(Access =
public)
59 %> Construct and
return a scalar
object of
class [pm.io.FileContentsTabular](@ref
FileContentsTabular).
62 %> This is the constructor of the
class [pm.io.FileContentsTabular](@ref
FileContentsTabular).
64 %> \param[in] file : See the documentation of the corresponding argument of [pm.io.FileContents](@ref
FileContents).
65 %> \param[in] silent : See the documentation of the corresponding argument of [pm.io.FileContents](@ref
FileContents).
66 %> \param[in] sep : The input scalar MATLAB
string containing the field separator used in the file.<br>
67 %> (**optional**. The
default is inferred from the contents of the specified input ``file``.)
70 %> ``self`` : The output scalar
object of
class [pm.io.FileContentsTabular](@ref
FileContentsTabular).
76 %> contents = pm.io.FileContentsTabular(file, [])
77 %> contents = pm.io.FileContentsTabular(file, silent)
78 %> contents = pm.io.FileContentsTabular(file, [], [])
79 %> contents = pm.io.FileContentsTabular(file, [], sep)
80 %> contents = pm.io.FileContentsTabular(file, silent, [])
81 %> contents = pm.io.FileContentsTabular(file, silent, sep)
88 %> \JoshuaOsborne, May 21 2024, 6:11 PM, University of Texas at Arlington<br>
89 %> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
90 %> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
101 self = self@pm.io.FileContents(file, silent);
102 if ~isfile(self.file)
104 + "The specified input file:" + newline ...
106 + pm.io.
tab + """" + self.file + """" + newline ...
108 + "does not exist." + newline ...
112 if pm.array.
len(sep) == 0
113 [d, self.sep, ~] = importdata(self.file);
114 elseif length(convertStringsToChars(sep)) == 1
115 [d, self.sep, ~] = importdata(self.file, sep);
119 + "Multicharacter separators are unsupported as of ParaMonte 2." + newline ...
120 + "You have specified sep = """ + sep + """." + newline ...
121 + "If this feature is desired, please report this request at:" + newline ...
129 + "The specified input file is empty:" + newline ...
131 + pm.io.
tab + self.file + newline ...
134 elseif ~isfield(d, "colheaders") || ~isfield(d, "data")
136 + "The specified input file is not a table:" + newline ...
138 + pm.io.
tab + self.file + newline ...
140 + "The
choice of field separator (""" + sep + """) may be incorrect." + newline ...
144 self.ncol = size(d.data, 2);
145 self.nrow = size(d.data, 1);
146 self.df = array2table(d.data, 'VariableNames', d.colheaders);
149 disp("ncol = " +
string(self.ncol) + ", nrow = " +
string(self.nrow));
function choice()
Return the ParaMonte-preferred MPI library vendor name as used in naming the ParaMonte MATLAB shared ...
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 weblinks()
Return a structure containing tree of weblinks for the ParaMonte MATLAB library source file and docum...