diff data/fileio/CSVStreamWriter.h @ 1449:deabf9fd3d28 streaming-csv-writer

Add failing test case for writing a sparse model. Partially handle some of the related issues with line-breaks.
author Lucas Thompson <dev@lucas.im>
date Tue, 17 Apr 2018 10:03:51 +0100
parents 5bd240517c1a
children 6e9615bde1f9
line wrap: on
line diff
--- a/data/fileio/CSVStreamWriter.h	Tue Apr 17 10:03:50 2018 +0100
+++ b/data/fileio/CSVStreamWriter.h	Tue Apr 17 10:03:51 2018 +0100
@@ -68,13 +68,17 @@
 
             const auto start = readPtr;
             const auto end = std::min(start + blockSize, endFrame);
-
-            oss << model.toDelimitedDataStringSubsetWithOptions(
+            const auto data = model.toDelimitedDataStringSubsetWithOptions(
                 delimiter,
                 options,
                 start,
                 end
-            ) << (end < finalFrameOfLastRegion ? "\n" : "");
+            ).trimmed();
+
+            if ( data != "" ) {
+                oss << data << (end < finalFrameOfLastRegion ? "\n" : "");
+            }
+
             nFramesWritten += end - start;
             const auto currentProgress = 100 * nFramesWritten / nFramesToWrite;
             const bool hasIncreased = currentProgress > previousProgress;