MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / insertColumn

Method insertColumn

src/csvdatastorage.cpp:351–364  ·  view source on GitHub ↗

insertColumn(long C, bool before=false) Insert a column after column `C`, or before if `before` is true. // a simple solution based on tableData.at(i).insert() throws std::bad_alloc execptions, // if the container is big (e.g. 500000 lines) – not the case anymore?? */

Source from the content-addressed store, hash-verified

349 // if the container is big (e.g. 500000 lines) – not the case anymore??
350 */
351void CsvDataStorage::insertColumn(table_index_t C, bool before) {
352 table_index_t R = rows();
353 if( C >= 0 && C < columns() ) {
354 for( table_index_t r = 0; r < R; ++r ) {
355 std::vector<std::string> row = splitString(tableData.at(r));
356 if( before )
357 row.insert(row.begin() + C, "");
358 else
359 row.insert(row.begin() + C + 1, "");
360 tableData.at(r) = mergeString(row);
361 }
362 ++numColumns;
363 }
364}
365
366
367

Callers 1

addColMethod · 0.80

Calls 3

atMethod · 0.80
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected