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?? */
| 349 | // if the container is big (e.g. 500000 lines) – not the case anymore?? |
| 350 | */ |
| 351 | void 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 |