comparison transform/CSVFeatureWriter.cpp @ 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 fdf5930b7ccc
children 4541581067f3
comparison
equal deleted inserted replaced
513:06a6612e7cf1 514:6acdddf6f99e
83 83
84 QTextStream &stream = *sptr; 84 QTextStream &stream = *sptr;
85 85
86 for (unsigned int i = 0; i < features.size(); ++i) { 86 for (unsigned int i = 0; i < features.size(); ++i) {
87 87
88 if (m_stdout || m_singleFileName != "") {
89 if (trackId != m_prevPrintedTrackId) {
90 stream << "\"" << trackId << "\"" << m_separator;
91 m_prevPrintedTrackId = trackId;
92 } else {
93 stream << m_separator;
94 }
95 }
96
88 QString timestamp = features[i].timestamp.toString().c_str(); 97 QString timestamp = features[i].timestamp.toString().c_str();
89 timestamp.replace(QRegExp("^ +"), ""); 98 timestamp.replace(QRegExp("^ +"), "");
99 stream << timestamp;
90 100
91 stream << timestamp; 101 if (features[i].hasDuration) {
102 QString duration = features[i].duration.toString().c_str();
103 duration.replace(QRegExp("^ +"), "");
104 stream << m_separator << duration;
105 }
92 106
93 if (summaryType != "") { 107 if (summaryType != "") {
94 stream << m_separator << summaryType.c_str(); 108 stream << m_separator << summaryType.c_str();
95 } 109 }
96 110
97 for (unsigned int j = 0; j < features[i].values.size(); ++j) { 111 for (unsigned int j = 0; j < features[i].values.size(); ++j) {
98 stream << m_separator << features[i].values[j]; 112 stream << m_separator << features[i].values[j];
99 } 113 }
100 114
115 if (features[i].label != "") {
116 stream << m_separator << "\"" << features[i].label.c_str() << "\"";
117 }
118
101 stream << "\n"; 119 stream << "\n";
102 } 120 }
103 } 121 }
104 122
105 123