www.mooseframework.org
Public Types | Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | List of all members
MooseUtils::DelimitedFileReader Class Reference

Utility class for reading delimited data (e.g., CSV data). More...

#include <DelimitedFileReader.h>

Public Types

enum  HeaderFlag { HeaderFlag::OFF = 0, HeaderFlag::ON = 1, HeaderFlag::AUTO = 2 }
 
enum  FormatFlag { FormatFlag::COLUMNS = 0, FormatFlag::ROWS = 1 }
 

Public Member Functions

 DelimitedFileReader (const std::string &filename, const libMesh::Parallel::Communicator *comm=nullptr)
 
void read ()
 Perform the actual data reading. More...
 
const std::vector< std::string > & getNames () const
 Return the column/row names. More...
 
const std::vector< std::vector< double > > & getData () const
 Return the rows/columns of data. More...
 
void setIgnoreEmptyLines (bool value)
 Set/Get methods for file format controls. More...
 
bool getIgnoreEmptyLines () const
 
void setFormatFlag (FormatFlag value)
 
FormatFlag getFormatFlag () const
 
void setDelimiter (const std::string &value)
 
const std::string & setDelimiter () const
 
void setHeaderFlag (HeaderFlag value)
 
HeaderFlag getHeaderFlag () const
 
void setComment (const std::string &value)
 
const std::string & getComment () const
 
const std::vector< double > & getData (const std::string &name) const
 Return the row/column of data for a specified header entry. More...
 
const std::vector< double > & getData (std::size_t index) const
 
void setHeaderFlag (bool value)
 Deprecated. More...
 
const std::vector< std::string > & getColumnNames () const
 
const std::vector< std::vector< double > > & getColumnData () const
 
const std::vector< double > & getColumnData (const std::string &name) const
 
 DelimitedFileReader (const std::string &filename, const bool header, const std::string delimiter, const libMesh::Parallel::Communicator *comm=nullptr)
 

Public Attributes

const std::size_t INVALID_SIZE = std::numeric_limits<std::size_t>::max()
 

Protected Attributes

const std::string _filename
 The supplied filename. More...
 
HeaderFlag _header_flag
 Flag indicating if the file contains a header. More...
 
std::string _delimiter
 The delimiter separating the supplied data entires. More...
 
bool _ignore_empty_lines
 Flag for ignoring empty lines. More...
 
std::vector< std::string > _names
 Storage for the read or generated column names. More...
 
std::vector< std::vector< double > > _data
 Storage for the read data columns. More...
 
const libMesh::Parallel::Communicator * _communicator
 Communicator. More...
 
FormatFlag _format_flag
 Format "rows" vs "columns". More...
 
std::vector< std::size_t > _row_offsets
 Row offsets (only used with _format == "rows") More...
 
std::string _row_comment
 Hide row comments. More...
 

Private Member Functions

void processLine (const std::string &line, std::vector< double > &row, const unsigned int &num)
 Populate supplied vector with content from line. More...
 
bool preprocessLine (std::string &line, const unsigned int &num)
 Check the content of the line and if it should be skipped. More...
 
const std::string & delimiter (const std::string &line)
 Determine the delimiter. More...
 
bool header (const std::string &line)
 Return the header flag, if it is set to AUTO attempt to determine if a header exists in line. More...
 
void readColumnData (std::ifstream &stream_data, std::vector< double > &output)
 Read the numeric data as rows or columns into a single vector. More...
 
void readRowData (std::ifstream &stream_data, std::vector< double > &output)
 

Detailed Description

Utility class for reading delimited data (e.g., CSV data).

Parameters
filenameA string for the filename to read.
commA pointer to a Communicator object (see below).

This class assumes that all data is numeric and can be converted to a C++ double. If a Communicator is provide then it will only read on processor 0 and broadcast the data to all processors. If not provided it will read on all processors.

Definition at line 40 of file DelimitedFileReader.h.

Member Enumeration Documentation

Enumerator
COLUMNS 
ROWS 

Definition at line 50 of file DelimitedFileReader.h.

51  {
52  COLUMNS = 0,
53  ROWS = 1
54  };
Enumerator
OFF 
ON 
AUTO 

Definition at line 43 of file DelimitedFileReader.h.

44  {
45  OFF = 0,
46  ON = 1,
47  AUTO = 2
48  };

Constructor & Destructor Documentation

MooseUtils::DelimitedFileReader::DelimitedFileReader ( const std::string &  filename,
const libMesh::Parallel::Communicator *  comm = nullptr 
)

Definition at line 29 of file DelimitedFileReader.C.

Referenced by getComment().

31  : _filename(filename),
33  _ignore_empty_lines(true),
36 {
37 }
HeaderFlag _header_flag
Flag indicating if the file contains a header.
bool _ignore_empty_lines
Flag for ignoring empty lines.
FormatFlag _format_flag
Format "rows" vs "columns".
const libMesh::Parallel::Communicator * _communicator
Communicator.
const std::string _filename
The supplied filename.
MPI_Comm comm
MooseUtils::DelimitedFileReader::DelimitedFileReader ( const std::string &  filename,
const bool  header,
const std::string  delimiter,
const libMesh::Parallel::Communicator *  comm = nullptr 
)

Definition at line 362 of file DelimitedFileReader.C.

366  : _filename(filename),
369  _ignore_empty_lines(true),
372 {
373  mooseDeprecated("Use setHeader and setDelimiter method rather than specifying in constructor.");
374 }
std::string _delimiter
The delimiter separating the supplied data entires.
HeaderFlag _header_flag
Flag indicating if the file contains a header.
bool _ignore_empty_lines
Flag for ignoring empty lines.
void mooseDeprecated(Args &&...args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:202
FormatFlag _format_flag
Format "rows" vs "columns".
bool header(const std::string &line)
Return the header flag, if it is set to AUTO attempt to determine if a header exists in line...
const libMesh::Parallel::Communicator * _communicator
Communicator.
const std::string _filename
The supplied filename.
MPI_Comm comm
const std::string & delimiter(const std::string &line)
Determine the delimiter.

Member Function Documentation

const std::string & MooseUtils::DelimitedFileReader::delimiter ( const std::string &  line)
private

Determine the delimiter.

If the setDelimiter method is not called the data is inspected, if a ',' is found it is assumed to be the delimiter as is the case for . Otherwise a space is used.

Definition at line 323 of file DelimitedFileReader.C.

Referenced by getComment(), header(), processLine(), readColumnData(), and readRowData().

324 {
325  if (_delimiter.empty())
326  {
327  if (line.find(",") != std::string::npos)
328  _delimiter = ",";
329  else if (line.find("\t") != std::string::npos)
330  _delimiter = "\t";
331  else
332  _delimiter = " ";
333  }
334  return _delimiter;
335 }
std::string _delimiter
The delimiter separating the supplied data entires.
const std::vector< std::vector< double > > & MooseUtils::DelimitedFileReader::getColumnData ( ) const

Definition at line 384 of file DelimitedFileReader.C.

Referenced by getComment().

385 {
386  mooseDeprecated("Use getData instead.");
387  return getData();
388 }
void mooseDeprecated(Args &&...args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:202
const std::vector< std::vector< double > > & getData() const
Return the rows/columns of data.
const std::vector< double > & MooseUtils::DelimitedFileReader::getColumnData ( const std::string &  name) const

Definition at line 391 of file DelimitedFileReader.C.

392 {
393  mooseDeprecated("Use getData instead.");
394  return getData(name);
395 }
void mooseDeprecated(Args &&...args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:202
const std::vector< std::vector< double > > & getData() const
Return the rows/columns of data.
const std::vector< std::string > & MooseUtils::DelimitedFileReader::getColumnNames ( ) const

Definition at line 377 of file DelimitedFileReader.C.

Referenced by getComment().

378 {
379  mooseDeprecated("Use getNames instead.");
380  return getNames();
381 }
const std::vector< std::string > & getNames() const
Return the column/row names.
void mooseDeprecated(Args &&...args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:202
const std::string& MooseUtils::DelimitedFileReader::getComment ( ) const
inline

Definition at line 91 of file DelimitedFileReader.h.

91 { return _row_comment; }
std::string _row_comment
Hide row comments.
const std::vector< std::vector< double > > & MooseUtils::DelimitedFileReader::getData ( ) const

Return the rows/columns of data.

The outer vector is column and the inner the rows.

Definition at line 135 of file DelimitedFileReader.C.

Referenced by Piecewise::buildFromFile(), CSVReader::execute(), getColumnData(), getComment(), and CSVTimeSequenceStepper::init().

136 {
137  return _data;
138 }
std::vector< std::vector< double > > _data
Storage for the read data columns.
const std::vector< double > & MooseUtils::DelimitedFileReader::getData ( const std::string &  name) const

Return the row/column of data for a specified header entry.

Definition at line 141 of file DelimitedFileReader.C.

142 {
143  const auto it = find(_names.begin(), _names.end(), name);
144  if (it == _names.end())
145  mooseError("Could not find '", name, "' in header of file ", _filename, ".");
146  return _data[std::distance(_names.begin(), it)];
147 }
std::vector< std::vector< double > > _data
Storage for the read data columns.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::vector< std::string > _names
Storage for the read or generated column names.
const std::string _filename
The supplied filename.
const std::vector< double > & MooseUtils::DelimitedFileReader::getData ( std::size_t  index) const

Definition at line 150 of file DelimitedFileReader.C.

151 {
152  if (index >= _data.size())
153  mooseError("The supplied index ",
154  index,
155  " is out-of-range for the available data in file '",
156  _filename,
157  "' which contains ",
158  _data.size(),
159  " items.");
160  return _data[index];
161 }
std::vector< std::vector< double > > _data
Storage for the read data columns.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
const std::string _filename
The supplied filename.
FormatFlag MooseUtils::DelimitedFileReader::getFormatFlag ( ) const
inline

Definition at line 82 of file DelimitedFileReader.h.

82 { return _format_flag; }
FormatFlag _format_flag
Format "rows" vs "columns".
HeaderFlag MooseUtils::DelimitedFileReader::getHeaderFlag ( ) const
inline

Definition at line 88 of file DelimitedFileReader.h.

88 { return _header_flag; }
HeaderFlag _header_flag
Flag indicating if the file contains a header.
bool MooseUtils::DelimitedFileReader::getIgnoreEmptyLines ( ) const
inline

Definition at line 79 of file DelimitedFileReader.h.

79 { return _ignore_empty_lines; }
bool _ignore_empty_lines
Flag for ignoring empty lines.
const std::vector< std::string > & MooseUtils::DelimitedFileReader::getNames ( ) const

Return the column/row names.

Definition at line 129 of file DelimitedFileReader.C.

Referenced by CSVReader::execute(), getColumnNames(), getComment(), and CSVReader::initialize().

130 {
131  return _names;
132 }
std::vector< std::string > _names
Storage for the read or generated column names.
bool MooseUtils::DelimitedFileReader::header ( const std::string &  line)
private

Return the header flag, if it is set to AUTO attempt to determine if a header exists in line.

Definition at line 338 of file DelimitedFileReader.C.

Referenced by getComment(), readColumnData(), and readRowData().

339 {
340  switch (_header_flag)
341  {
342  case HeaderFlag::OFF:
343  return false;
344  case HeaderFlag::ON:
345  return true;
346  default:
347 
348  // Attempt to convert the line, if it fails assume it is a header
349  std::vector<double> row;
350  bool contains_alpha = !MooseUtils::tokenizeAndConvert<double>(line, row, delimiter(line));
351 
352  // Based on auto detect set the flag to TRUE|FALSE to short-circuit this check for each line
353  // in the case of row data.
354  _header_flag = contains_alpha ? HeaderFlag::ON : HeaderFlag::OFF;
355  return contains_alpha;
356  }
357 }
HeaderFlag _header_flag
Flag indicating if the file contains a header.
const std::string & delimiter(const std::string &line)
Determine the delimiter.
bool MooseUtils::DelimitedFileReader::preprocessLine ( std::string &  line,
const unsigned int &  num 
)
private

Check the content of the line and if it should be skipped.

Parameters
lineComplete line being read.
numThe current line number.
Returns
True if the line should be skipped.

Definition at line 287 of file DelimitedFileReader.C.

Referenced by readColumnData(), and readRowData().

288 {
289  // Handle row comments
290  std::size_t index = _row_comment.empty() ? line.size() : line.find_first_of(_row_comment);
291  line = MooseUtils::trim(line.substr(0, index));
292 
293  // Ignore empty lines
294  if (line.empty())
295  {
297  return true;
298  else
299  mooseError("Failed to read line ", num, " in file ", _filename, ". The line is empty.");
300  }
301  return false;
302 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
bool _ignore_empty_lines
Flag for ignoring empty lines.
const std::string _filename
The supplied filename.
std::string trim(const std::string &str, const std::string &white_space=" \t\n\v\f\r")
Standard scripting language trim function.
Definition: MooseUtils.C:95
std::string _row_comment
Hide row comments.
void MooseUtils::DelimitedFileReader::processLine ( const std::string &  line,
std::vector< double > &  row,
const unsigned int &  num 
)
private

Populate supplied vector with content from line.

Parameters
lineThe line to extract data from.
rowThe vector to populate.
numThe current line number.

Definition at line 305 of file DelimitedFileReader.C.

Referenced by readColumnData(), and readRowData().

308 {
309  // Separate the row and error if it fails
310  bool status = MooseUtils::tokenizeAndConvert<double>(line, row, delimiter(line));
311  if (!status)
312  mooseError("Failed to convert a delimited data into double when reading line ",
313  num,
314  " in file ",
315  _filename,
316  ".\n LINE ",
317  num,
318  ": ",
319  line);
320 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
const std::string _filename
The supplied filename.
const std::string & delimiter(const std::string &line)
Determine the delimiter.
void MooseUtils::DelimitedFileReader::read ( )

Perform the actual data reading.

This is a separate method to allow for the filename to be read multiple times.

Definition at line 40 of file DelimitedFileReader.C.

Referenced by Piecewise::buildFromFile(), CSVTimeSequenceStepper::init(), and CSVReader::initialize().

41 {
42  // Number of columns
43  std::size_t n_cols;
44 
45  // Storage for the raw data
46  std::vector<double> raw;
47  std::size_t size_raw = 0;
48  std::size_t size_offsets = 0;
49 
50  // Read data
51  if (_communicator == nullptr || _communicator->rank() == 0)
52  {
53  // Check the file
55 
56  // Create the file stream and do nothing if the file is empty
57  std::ifstream stream_data(_filename);
58  if (stream_data.peek() == std::ifstream::traits_type::eof())
59  return;
60 
61  // Read/generate the header
63  readRowData(stream_data, raw);
64  else
65  readColumnData(stream_data, raw);
66 
67  // Set the number of columns
68  n_cols = _names.size();
69 
70  // Close the stream
71  stream_data.close();
72 
73  // Set raw data vector size
74  size_raw = raw.size();
75  size_offsets = _row_offsets.size();
76  }
77 
78  if (_communicator != nullptr)
79  {
80  // Broadcast column names
81  _communicator->broadcast(n_cols);
82  _names.resize(n_cols);
83  _communicator->broadcast(_names);
84 
85  // Broadcast raw data
86  _communicator->broadcast(size_raw);
87  raw.resize(size_raw);
88  _communicator->broadcast(raw);
89 
90  // Broadcast row offsets
92  {
93  _communicator->broadcast(size_offsets);
94  _row_offsets.resize(size_offsets);
95  _communicator->broadcast(_row_offsets);
96  }
97  }
98 
99  // Resize the internal storage
100  _data.resize(n_cols);
101 
102  // Process "row" formatted data
104  {
105  std::vector<double>::iterator start = raw.begin();
106  for (std::size_t j = 0; j < n_cols; ++j)
107  {
108  _data[j] = std::vector<double>(start, start + _row_offsets[j]);
109  std::advance(start, _row_offsets[j]);
110  }
111  }
112 
113  // Process "column" formatted data
114  else
115  {
116  mooseAssert(raw.size() % n_cols == 0,
117  "The raw data is not evenly divisible by the number of columns.");
118  const std::size_t n_rows = raw.size() / n_cols;
119  for (std::size_t j = 0; j < n_cols; ++j)
120  {
121  _data[j].resize(n_rows);
122  for (std::size_t i = 0; i < n_rows; ++i)
123  _data[j][i] = raw[i * n_cols + j];
124  }
125  }
126 }
std::vector< std::vector< double > > _data
Storage for the read data columns.
std::vector< std::string > _names
Storage for the read or generated column names.
FormatFlag _format_flag
Format "rows" vs "columns".
bool checkFileReadable(const std::string &filename, bool check_line_endings=false, bool throw_on_unreadable=true)
Checks to see if a file is readable (exists and permissions)
Definition: MooseUtils.C:121
const libMesh::Parallel::Communicator * _communicator
Communicator.
void readColumnData(std::ifstream &stream_data, std::vector< double > &output)
Read the numeric data as rows or columns into a single vector.
const std::string _filename
The supplied filename.
void readRowData(std::ifstream &stream_data, std::vector< double > &output)
std::vector< std::size_t > _row_offsets
Row offsets (only used with _format == "rows")
void MooseUtils::DelimitedFileReader::readColumnData ( std::ifstream &  stream_data,
std::vector< double > &  output 
)
private

Read the numeric data as rows or columns into a single vector.

Definition at line 164 of file DelimitedFileReader.C.

Referenced by read().

165 {
166  // Local storage for the data being read
167  std::string line;
168  std::vector<double> row;
169 
170  // Keep track of the line number for error reporting
171  unsigned int count = 0;
172 
173  // Number of columns expected based on the first row of the data
174  std::size_t n_cols = INVALID_SIZE;
175 
176  // Read the lines
177  while (std::getline(stream_data, line))
178  {
179  // Increment line counter and clear any tokenized data
180  count++;
181  row.clear();
182 
183  // Ignore empty and/or comment lines, if applicable
184  if (preprocessLine(line, count))
185  continue;
186 
187  // Read header, if the header exists and the column names do not exist.
188  if (_names.empty() && header(line))
189  {
190  MooseUtils::tokenize(line, _names, 1, delimiter(line));
191  for (std::string & str : _names)
192  str = MooseUtils::trim(str);
193  continue;
194  }
195 
196  // Separate the row and error if it fails
197  processLine(line, row, count);
198 
199  // Set the number of columns
200  if (n_cols == INVALID_SIZE)
201  n_cols = row.size();
202 
203  // Check number of columns
204  if (row.size() != n_cols)
205  mooseError("The number of columns read (",
206  row.size(),
207  ") does not match the number of columns expected (",
208  n_cols,
209  ") based on the first row of the file when reading row ",
210  count,
211  " in file ",
212  _filename,
213  ".");
214 
215  // Append data
216  output.insert(output.end(), row.begin(), row.end());
217  }
218 
219  // If the names have not been assigned, create the default names
220  if (_names.empty())
221  {
222  _names.resize(n_cols);
223  int padding = MooseUtils::numDigits(n_cols);
224  for (std::size_t i = 0; i < n_cols; ++i)
225  {
226  std::stringstream ss;
227  ss << "column_" << std::setw(padding) << std::setfill('0') << i;
228  _names[i] = ss.str();
229  }
230  }
231 }
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
Definition: MooseUtils.h:350
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
bool preprocessLine(std::string &line, const unsigned int &num)
Check the content of the line and if it should be skipped.
std::vector< std::string > _names
Storage for the read or generated column names.
bool header(const std::string &line)
Return the header flag, if it is set to AUTO attempt to determine if a header exists in line...
const std::string _filename
The supplied filename.
int numDigits(const T &num)
Return the number of digits for a number.
Definition: MooseUtils.h:445
std::string trim(const std::string &str, const std::string &white_space=" \t\n\v\f\r")
Standard scripting language trim function.
Definition: MooseUtils.C:95
const std::string & delimiter(const std::string &line)
Determine the delimiter.
void processLine(const std::string &line, std::vector< double > &row, const unsigned int &num)
Populate supplied vector with content from line.
void MooseUtils::DelimitedFileReader::readRowData ( std::ifstream &  stream_data,
std::vector< double > &  output 
)
private

Definition at line 234 of file DelimitedFileReader.C.

Referenced by read().

235 {
236  // Local storage for the data being read
237  std::string line;
238  std::vector<double> row;
239  unsigned int linenum = 0; // line number in file
240 
241  // Clear existing data
242  _names.clear();
243  _row_offsets.clear();
244 
245  // Read the lines
246  while (std::getline(stream_data, line))
247  {
248  // Increment line counter and clear any tokenized data
249  linenum++;
250  row.clear();
251 
252  // Ignore empty lines
253  if (preprocessLine(line, linenum))
254  continue;
255 
256  if (header(line))
257  {
258  std::size_t index = line.find_first_of(delimiter(line));
259  _names.push_back(line.substr(0, index));
260  line = line.substr(index);
261  }
262 
263  // Separate the row and error if it fails
264  processLine(line, row, linenum);
265 
266  // Store row offsets to allow for un-even rows
267  _row_offsets.push_back(row.size());
268 
269  // Append data
270  output.insert(output.end(), row.begin(), row.end());
271  }
272 
273  // Assign row names if not provided via header
274  if (_names.empty())
275  {
276  int padding = MooseUtils::numDigits(_row_offsets.size());
277  for (std::size_t i = 0; i < _row_offsets.size(); ++i)
278  {
279  std::stringstream ss;
280  ss << "row_" << std::setw(padding) << std::setfill('0') << i;
281  _names.push_back(ss.str());
282  }
283  }
284 }
bool preprocessLine(std::string &line, const unsigned int &num)
Check the content of the line and if it should be skipped.
std::vector< std::string > _names
Storage for the read or generated column names.
bool header(const std::string &line)
Return the header flag, if it is set to AUTO attempt to determine if a header exists in line...
int numDigits(const T &num)
Return the number of digits for a number.
Definition: MooseUtils.h:445
const std::string & delimiter(const std::string &line)
Determine the delimiter.
std::vector< std::size_t > _row_offsets
Row offsets (only used with _format == "rows")
void processLine(const std::string &line, std::vector< double > &row, const unsigned int &num)
Populate supplied vector with content from line.
void MooseUtils::DelimitedFileReader::setComment ( const std::string &  value)
inline

Definition at line 90 of file DelimitedFileReader.h.

Referenced by Piecewise::buildFromFile().

90 { _row_comment = value; }
std::string _row_comment
Hide row comments.
void MooseUtils::DelimitedFileReader::setDelimiter ( const std::string &  value)
inline

Definition at line 84 of file DelimitedFileReader.h.

Referenced by CSVReader::CSVReader(), and CSVTimeSequenceStepper::init().

84 { _delimiter = value; }
std::string _delimiter
The delimiter separating the supplied data entires.
const std::string& MooseUtils::DelimitedFileReader::setDelimiter ( ) const
inline

Definition at line 85 of file DelimitedFileReader.h.

85 { return _delimiter; }
std::string _delimiter
The delimiter separating the supplied data entires.
void MooseUtils::DelimitedFileReader::setFormatFlag ( FormatFlag  value)
inline

Definition at line 81 of file DelimitedFileReader.h.

Referenced by Piecewise::buildFromFile().

81 { _format_flag = value; }
FormatFlag _format_flag
Format "rows" vs "columns".
void MooseUtils::DelimitedFileReader::setHeaderFlag ( HeaderFlag  value)
inline

Definition at line 87 of file DelimitedFileReader.h.

Referenced by CSVReader::CSVReader(), getComment(), and CSVTimeSequenceStepper::init().

87 { _header_flag = value; }
HeaderFlag _header_flag
Flag indicating if the file contains a header.
void MooseUtils::DelimitedFileReader::setHeaderFlag ( bool  value)

Deprecated.

Definition at line 398 of file DelimitedFileReader.C.

399 {
400  mooseDeprecated("Use header method with HeaderFlag input.");
402 }
HeaderFlag _header_flag
Flag indicating if the file contains a header.
void mooseDeprecated(Args &&...args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:202
void MooseUtils::DelimitedFileReader::setIgnoreEmptyLines ( bool  value)
inline

Set/Get methods for file format controls.

IgnoreEmptyLines: When true all empty lines are ignored, when false an error is produced. FormatFlag: Set the file format (rows vs. columns). Delimiter: Set the file delimiter (if unset it will be detected). HeaderFlag: Set the header flag (TRUE used the first row has header, FALSE assumes no header, and AUTO will attempt to determine if a header exists). Comment: Set the comment character, by default no comment character is used.

Definition at line 78 of file DelimitedFileReader.h.

Referenced by CSVReader::CSVReader().

78 { _ignore_empty_lines = value; }
bool _ignore_empty_lines
Flag for ignoring empty lines.

Member Data Documentation

const libMesh::Parallel::Communicator* MooseUtils::DelimitedFileReader::_communicator
protected

Communicator.

Definition at line 148 of file DelimitedFileReader.h.

Referenced by read().

std::vector<std::vector<double> > MooseUtils::DelimitedFileReader::_data
protected

Storage for the read data columns.

Definition at line 145 of file DelimitedFileReader.h.

Referenced by getData(), and read().

std::string MooseUtils::DelimitedFileReader::_delimiter
protected

The delimiter separating the supplied data entires.

Definition at line 136 of file DelimitedFileReader.h.

Referenced by delimiter(), and setDelimiter().

const std::string MooseUtils::DelimitedFileReader::_filename
protected

The supplied filename.

Definition at line 130 of file DelimitedFileReader.h.

Referenced by getData(), preprocessLine(), processLine(), read(), and readColumnData().

FormatFlag MooseUtils::DelimitedFileReader::_format_flag
protected

Format "rows" vs "columns".

Definition at line 151 of file DelimitedFileReader.h.

Referenced by getFormatFlag(), read(), and setFormatFlag().

HeaderFlag MooseUtils::DelimitedFileReader::_header_flag
protected

Flag indicating if the file contains a header.

Definition at line 133 of file DelimitedFileReader.h.

Referenced by getHeaderFlag(), header(), and setHeaderFlag().

bool MooseUtils::DelimitedFileReader::_ignore_empty_lines
protected

Flag for ignoring empty lines.

Definition at line 139 of file DelimitedFileReader.h.

Referenced by getIgnoreEmptyLines(), preprocessLine(), and setIgnoreEmptyLines().

std::vector<std::string> MooseUtils::DelimitedFileReader::_names
protected

Storage for the read or generated column names.

Definition at line 142 of file DelimitedFileReader.h.

Referenced by getData(), getNames(), read(), readColumnData(), and readRowData().

std::string MooseUtils::DelimitedFileReader::_row_comment
protected

Hide row comments.

Definition at line 157 of file DelimitedFileReader.h.

Referenced by getComment(), preprocessLine(), and setComment().

std::vector<std::size_t> MooseUtils::DelimitedFileReader::_row_offsets
protected

Row offsets (only used with _format == "rows")

Definition at line 154 of file DelimitedFileReader.h.

Referenced by read(), and readRowData().

const std::size_t MooseUtils::DelimitedFileReader::INVALID_SIZE = std::numeric_limits<std::size_t>::max()

Definition at line 56 of file DelimitedFileReader.h.

Referenced by readColumnData().


The documentation for this class was generated from the following files: