diff --git a/lib/imc_channel.hpp b/lib/imc_channel.hpp index fe667ea..90f27a0 100644 --- a/lib/imc_channel.hpp +++ b/lib/imc_channel.hpp @@ -381,7 +381,7 @@ namespace imc } // print channel - void print(std::string filename, const char sep = ' ', int width = 25) + void print(std::string filename, const char sep = ',', int width = 25) { std::ofstream fou(filename); diff --git a/lib/imc_raw.hpp b/lib/imc_raw.hpp index 8e6b0cd..54092c8 100644 --- a/lib/imc_raw.hpp +++ b/lib/imc_raw.hpp @@ -333,7 +333,7 @@ namespace imc } // print all channels in directory - void print_channels(std::string output) + void print_channels(std::string output, const char sep) { // check for given directory std::filesystem::path pd = output; @@ -352,7 +352,7 @@ namespace imc std::filesystem::path pf = pd / filenam; // and print the channel - it->second.print(pf); + it->second.print(pf,sep); } } diff --git a/makefile b/makefile index 983a850..558b170 100644 --- a/makefile +++ b/makefile @@ -93,7 +93,7 @@ cython-install : check-vtag $(CTAG) $(CYT)setup.py $(CYT)imc_termite.pxd $(CYT)p cython-clean : rm -vf imc_termite.cpython-*.so rm -vf $(PYT)imc_termite.cpython-*.so - rm -rv build/ + rm -rvf build/ #-----------------------------------------------------------------------------# # pip diff --git a/src/main.cpp b/src/main.cpp index 9148d1c..69dc3ef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -66,6 +66,20 @@ optkeys parse_args(int argc, char* argv[], bool list_args = false) i = i + 1; } } + else if ( std::string(argv[i]) == std::string("--delimiter") + || std::string(argv[i]) == std::string("-s") ) + { + if ( i+1 == argc || argv[i+1][0] == '-' ) + { + std::cerr<<"invalid or missing --output argument\n"; + prsdkeys.insert(std::pair("invalid","delimiter")); + } + else + { + prsdkeys.insert(std::pair("delimiter",argv[i+1])); + i = i + 1; + } + } else if ( std::string(argv[i]) == std::string("--help") || std::string(argv[i]) == std::string("-h") ) { @@ -121,9 +135,13 @@ void show_usage() <<" -c, --listchannels list channels\n" <<" -b, --listblocks list IMC key-blocks\n" <<" -d, --output output directory to print channels\n" + <<" -s, --delimiter csv delimiter/separator char for output\n" <<" -h, --help show this help message \n" <<" -v, --version display version\n" - <<"\n"; + <<"\n" + <<"Example:" + <<" $ ./imctermite sample/data_A.raw -c -b -d ./data -s ','" + <<"\n\n"; } //---------------------------------------------------------------------------// @@ -209,7 +227,11 @@ int main(int argc, char* argv[]) if ( cfgopts.count("output") == 1 ) { try { - imcraw.print_channels(cfgopts.at("output")); + if ( cfgopts.at("delimiter").size() > 1 ) + { + throw std::runtime_error("invalid delimiter comprised of more than a single char"); + } + imcraw.print_channels(cfgopts.at("output"),cfgopts.at("delimiter")[0]); } catch (const std::exception& e) { std::cerr<<"failed to print channels for "<