Skip to content

Commit

Permalink
check
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Jan 8, 2025
1 parent 569f29e commit e96e5ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/src/Base/Stat/SampleImplementation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ class CSVParser
std::ifstream theFile(fileName_);
if (!theFile.is_open())
throw FileNotFoundException(HERE) << "Cannot open file '" << fileName_ << "'. Reason: " << std::strerror(errno);

if (fieldSeparator_ == decimalSeparator_)
throw InvalidArgumentException(HERE) << "The field separator must be different from the decimal separator";
rapidcsv::LabelParams pLabelParams(-1, -1);
rapidcsv::SeparatorParams pSeparatorParams(fieldSeparator_, true);
rapidcsv::ConverterParams pConverterParams;
Expand All @@ -335,6 +336,8 @@ class CSVParser
const String commentMarkers(ResourceMap::GetAsString("Sample-CommentMarker"));
if (commentMarkers.size() != 1)
throw InvalidArgumentException(HERE) << "The entry Sample-CommentMarker must be a string of size 1";
if (allowEmptyLines_ && (commentMarkers[0] == fieldSeparator_ || commentMarkers[0] == decimalSeparator_))
throw InvalidArgumentException(HERE) << "The comment marker must be different from the field and decimal separators";
pLineReaderParams.mCommentPrefix = commentMarkers[0];
pLineReaderParams.mSkipEmptyLines = allowEmptyLines_;
pLineReaderParams.mSkippedLinesCount = skippedLinesNumber_;
Expand Down
6 changes: 3 additions & 3 deletions python/src/Sample_doc.i.in
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ used for setting the sample description using :py:meth:`setDescription`.

This method allows for more permissive file formatting than :py:meth:`ImportFromCSVFile`:

- The column separator can be a whitespace
- Comments are allowed
- Empty lines are allowed
- The field separator can be a whitespace
- Comment, emtpy or skipped lines are allowed
- Decimal separator can be tweaked

The comment marker is defined by the `Sample-CommentsMarker` entry from :class:`~openturns.ResourceMap`.

Expand Down

0 comments on commit e96e5ed

Please sign in to comment.