From d4535bff097e2ae9415d1cd04bde01b5126ea8cf Mon Sep 17 00:00:00 2001 From: Marc Sturm Date: Tue, 14 Jan 2025 09:26:14 +0100 Subject: [PATCH] TsvSlice: added parameter 'rm' --- src/TsvSlice/main.cpp | 12 +++ src/tools-TEST/TsvSlice_Test.h | 11 ++- src/tools-TEST/data_out/TsvSlice_out2.tsv | 104 ++++++++++++++++++++++ 3 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 src/tools-TEST/data_out/TsvSlice_out2.tsv diff --git a/src/TsvSlice/main.cpp b/src/TsvSlice/main.cpp index c08552a54..2b93e2d9e 100644 --- a/src/TsvSlice/main.cpp +++ b/src/TsvSlice/main.cpp @@ -24,6 +24,7 @@ class ConcreteTool addInfile("in", "Input TSV file. If unset, reads from STDIN.", true); addOutfile("out", "Output file. If unset, writes to STDOUT.", true); addFlag("numeric", "If set, column names are interpreted as 1-based column numbers."); + addFlag("rm", "If set, the columns given in 'cols' are removed instead of extracted."); } virtual void main() @@ -40,6 +41,17 @@ class ConcreteTool //check columns QVector cols = instream.checkColumns(getString("cols").toUtf8().split(','), getFlag("numeric")); + //remove instead of extract > invert column selection + if (getFlag("rm")) + { + QSet old = cols.toList().toSet(); + cols.clear(); + for (int c=0; c