MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / getColumnAsStringVector

Method getColumnAsStringVector

src/utilities/filetypes/CSVFile.cpp:298–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296 }
297
298 std::vector<std::string> CSVFile_Impl::getColumnAsStringVector(unsigned columnIndex) const {
299 if (columnIndex >= m_numColumns) {
300 LOG(Warn, "Column index " << columnIndex << " invalid for number of columns " << m_numColumns);
301 return {};
302 }
303
304 std::vector<std::string> result;
305
306 unsigned numRows = m_rows.size();
307 for (unsigned i = 0; i < numRows; ++i) {
308
309 if (m_rows[i][columnIndex].variantType() == VariantType::String) {
310 result.push_back(m_rows[i][columnIndex].valueAsString());
311 } else if (m_rows[i][columnIndex].variantType() == VariantType::Double) {
312 std::stringstream ss;
313 ss << m_rows[i][columnIndex].valueAsDouble();
314 result.push_back(ss.str());
315 } else if (m_rows[i][columnIndex].variantType() == VariantType::Integer) {
316 std::stringstream ss;
317 ss << m_rows[i][columnIndex].valueAsInteger();
318 result.push_back(ss.str());
319 }
320 }
321
322 return result;
323 }
324
325 // throws on error
326 std::vector<std::vector<Variant>> CSVFile_Impl::parseRows(std::istream& input) {

Callers 1

TESTFunction · 0.80

Calls 7

sizeMethod · 0.45
variantTypeMethod · 0.45
push_backMethod · 0.45
valueAsStringMethod · 0.45
valueAsDoubleMethod · 0.45
strMethod · 0.45
valueAsIntegerMethod · 0.45

Tested by 1

TESTFunction · 0.64