changeset 514:6acdddf6f99e

* fixes to improve the utility of the CSV feature writer
author Chris Cannam
date Wed, 10 Dec 2008 13:21:10 +0000
parents 06a6612e7cf1
children 1aefb666ecfc
files transform/CSVFeatureWriter.cpp transform/CSVFeatureWriter.h transform/FileFeatureWriter.cpp
diffstat 3 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/transform/CSVFeatureWriter.cpp	Wed Dec 10 12:39:32 2008 +0000
+++ b/transform/CSVFeatureWriter.cpp	Wed Dec 10 13:21:10 2008 +0000
@@ -85,10 +85,24 @@
 
     for (unsigned int i = 0; i < features.size(); ++i) {
 
+        if (m_stdout || m_singleFileName != "") {
+            if (trackId != m_prevPrintedTrackId) {
+                stream << "\"" << trackId << "\"" << m_separator;
+                m_prevPrintedTrackId = trackId;
+            } else {
+                stream << m_separator;
+            }
+        }
+
         QString timestamp = features[i].timestamp.toString().c_str();
         timestamp.replace(QRegExp("^ +"), "");
+        stream << timestamp;
 
-        stream << timestamp;
+        if (features[i].hasDuration) {
+            QString duration = features[i].duration.toString().c_str();
+            duration.replace(QRegExp("^ +"), "");
+            stream << m_separator << duration;
+        }            
 
         if (summaryType != "") {
             stream << m_separator << summaryType.c_str();
@@ -98,6 +112,10 @@
             stream << m_separator << features[i].values[j];
         }
 
+        if (features[i].label != "") {
+            stream << m_separator << "\"" << features[i].label.c_str() << "\"";
+        }
+
         stream << "\n";
     }
 }
--- a/transform/CSVFeatureWriter.h	Wed Dec 10 12:39:32 2008 +0000
+++ b/transform/CSVFeatureWriter.h	Wed Dec 10 13:21:10 2008 +0000
@@ -53,6 +53,7 @@
 
 private:
     QString m_separator;
+    QString m_prevPrintedTrackId;
 };
 
 #endif
--- a/transform/FileFeatureWriter.cpp	Wed Dec 10 12:39:32 2008 +0000
+++ b/transform/FileFeatureWriter.cpp	Wed Dec 10 13:21:10 2008 +0000
@@ -184,11 +184,13 @@
     QString filename;
 
     if (m_manyFiles && transformId != "") {
-        filename = QString("%1-%2.%3").arg(basename).arg(transformId).arg(m_extension);
+        filename = QString("%1_%2.%3").arg(basename).arg(transformId).arg(m_extension);
     } else {
         filename = QString("%1.%2").arg(basename).arg(m_extension);
     }
 
+    filename.replace(':', '_'); // ':' not permitted in Windows
+
     filename = QDir(dirname).filePath(filename);
 
     if (QFileInfo(filename).exists() && !(m_force || m_append)) {