Commit d76e0306485e089eb0405a3d86fb51a53f0a0ad9

Authored by caotto
1 parent b6ff0861

When plotting a file, if the number of pivots in the directory and filename

don't match, use a single column with the name of the file being plotted
instead of quitting.

Signed-off-by: caotto <ottochar@gmail.com>
Showing 1 changed file with 8 additions and 2 deletions
sdk/core/plot.cpp
... ... @@ -326,8 +326,14 @@ struct RPlot
326 326 pivotItems = QVector< QSet<QString> >(pivotHeaders.size());
327 327 foreach (const QString &fileName, files) {
328 328 QStringList pivots = getPivots(fileName, false);
329   - if (pivots.size() != pivotHeaders.size())
330   - qFatal("Pivot size mismatch: [%s] [%s]", qPrintable(pivotHeaders.join(",")), qPrintable(pivots.join(",")));
  329 +
  330 + // If the number of pivots don't match, abandon the directory/filename labeling scheme
  331 + if (pivots.size() != pivotHeaders.size()) {
  332 + pivots.clear();
  333 + pivots.push_back(QFileInfo(fileName).completeBaseName());
  334 + pivotHeaders.clear();
  335 + pivotHeaders.push_back("File");
  336 + }
331 337 file.write(qPrintable(QString("tmp <- read.csv(\"%1\")\n").arg(fileName).replace("\\", "\\\\")));
332 338 for (int i=0; i<pivots.size(); i++) {
333 339 pivotItems[i].insert(pivots[i]);
... ...