comparison transform/CSVFeatureWriter.cpp @ 1002:c2316a3bbb81

Add omit-filename option to CSV writer (and test it while testing lab writer)
author Chris Cannam
date Wed, 15 Oct 2014 10:38:17 +0100
parents 51bf067de517
children d954e03274e8
comparison
equal deleted inserted replaced
1001:51bf067de517 1002:c2316a3bbb81
33 SupportStdOut, 33 SupportStdOut,
34 "csv"), 34 "csv"),
35 m_separator(","), 35 m_separator(","),
36 m_sampleTiming(false), 36 m_sampleTiming(false),
37 m_endTimes(false), 37 m_endTimes(false),
38 m_forceEnd(false) 38 m_forceEnd(false),
39 m_omitFilename(false)
39 { 40 {
40 } 41 }
41 42
42 CSVFeatureWriter::~CSVFeatureWriter() 43 CSVFeatureWriter::~CSVFeatureWriter()
43 { 44 {
56 Parameter p; 57 Parameter p;
57 58
58 p.name = "separator"; 59 p.name = "separator";
59 p.description = "Column separator for output. Default is \",\" (comma)."; 60 p.description = "Column separator for output. Default is \",\" (comma).";
60 p.hasArg = true; 61 p.hasArg = true;
62 pl.push_back(p);
63
64 p.name = "omit-filename";
65 p.description = "Omit the filename column. May result in confusion if sending more than one audio file's features to the same CSV output.";
66 p.hasArg = false;
61 pl.push_back(p); 67 pl.push_back(p);
62 68
63 p.name = "sample-timing"; 69 p.name = "sample-timing";
64 p.description = "Show timings as sample frame counts instead of in seconds."; 70 p.description = "Show timings as sample frame counts instead of in seconds.";
65 p.hasArg = false; 71 p.hasArg = false;
87 for (map<string, string>::iterator i = params.begin(); 93 for (map<string, string>::iterator i = params.begin();
88 i != params.end(); ++i) { 94 i != params.end(); ++i) {
89 cerr << i->first << " -> " << i->second << endl; 95 cerr << i->first << " -> " << i->second << endl;
90 if (i->first == "separator") { 96 if (i->first == "separator") {
91 m_separator = i->second.c_str(); 97 m_separator = i->second.c_str();
98 cerr << "m_separator = " << m_separator << endl;
99 if (m_separator == "\\t") {
100 m_separator = QChar::Tabulation;
101 }
92 } else if (i->first == "sample-timing") { 102 } else if (i->first == "sample-timing") {
93 m_sampleTiming = true; 103 m_sampleTiming = true;
94 } else if (i->first == "end-times") { 104 } else if (i->first == "end-times") {
95 m_endTimes = true; 105 m_endTimes = true;
96 } else if (i->first == "fill-ends") { 106 } else if (i->first == "fill-ends") {
97 m_forceEnd = true; 107 m_forceEnd = true;
108 } else if (i->first == "omit-filename") {
109 m_omitFilename = true;
98 } 110 }
99 } 111 }
100 } 112 }
101 113
102 void 114 void
184 std::string summaryType) 196 std::string summaryType)
185 { 197 {
186 QString trackId = tt.first; 198 QString trackId = tt.first;
187 TransformId transformId = tt.second; 199 TransformId transformId = tt.second;
188 200
189 if (m_stdout || m_singleFileName != "") { 201 if (!m_omitFilename) {
190 if (trackId != m_prevPrintedTrackId) { 202 if (m_stdout || m_singleFileName != "") {
191 stream << "\"" << trackId << "\"" << m_separator; 203 if (trackId != m_prevPrintedTrackId) {
192 m_prevPrintedTrackId = trackId; 204 stream << "\"" << trackId << "\"" << m_separator;
193 } else { 205 m_prevPrintedTrackId = trackId;
194 stream << m_separator; 206 } else {
207 stream << m_separator;
208 }
195 } 209 }
196 } 210 }
197 211
198 Vamp::RealTime duration; 212 Vamp::RealTime duration;
199 bool haveDuration = true; 213 bool haveDuration = true;