From 0d20ea338eb98a9dfe4b0b666abe7d841dc672b1 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Tue, 19 Nov 2024 18:57:12 +1100 Subject: [PATCH] Fix out of bounds error. For Ravel #629. Also ignore blank labelled data columns (favour Excel artifact). --- engine/CSVParser.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/engine/CSVParser.cc b/engine/CSVParser.cc index 183f7e3b6..561d85274 100644 --- a/engine/CSVParser.cc +++ b/engine/CSVParser.cc @@ -477,7 +477,7 @@ bool DataSpec::processChunk(std::istream& input, const TokenizerFunction& tf, si const vector line(tok.begin(), tok.end()); if (line.size()>uniqueVals.size()) uniqueVals.resize(std::min(maxColumn, line.size())); - for (size_t i=0; iempty()) + horizontalLabels.emplace_back(sliceLabelTokens[""]); + else horizontalLabels.emplace_back (sliceLabelTokens[str(anyVal.back()(*field),spec.horizontalDimension.units)]); } @@ -701,7 +705,7 @@ namespace minsky set uniqueLabels; dimLabels.emplace_back(); for (auto& i: horizontalLabels) - if (uniqueLabels.insert(i).second) + if (!sliceLabelTokens[i].empty() && uniqueLabels.insert(i).second) { dimLabels.back()[i]=hc.xvectors.back().size(); hc.xvectors.back().emplace_back(sliceLabelTokens[i]); @@ -717,6 +721,7 @@ namespace minsky ++minsky().progressState; { + auto blankToken=sliceLabelTokens[""]; ProgressUpdater pu(minsky().progressState, "Reading data",1); for (; getWholeLine(input, buf, spec); ++row) { @@ -766,7 +771,11 @@ namespace minsky if ((spec.dataCols.empty() && col>=spec.nColAxes()) || spec.dataCols.contains(col) || col>=spec.maxColumn) { if (tabularFormat) - key.emplace_back(horizontalLabels[dataCols]); + { + if (horizontalLabels[dataCols]==blankToken) + continue; // ignore blank labelled columns + key.emplace_back(horizontalLabels[dataCols]); + } else if (dataCols) break; // only 1 value column, everything to right ignored