include/implement csvseparator option
This commit is contained in:
parent
02adaa7908
commit
529b80f4f9
@ -673,7 +673,7 @@ void tdm_reaper::print_channel(std::string &id, const char* filename, bool inclu
|
||||
fou.close();
|
||||
}
|
||||
|
||||
void tdm_reaper::print_group(std::string &id, const char* filename, bool include_meta)
|
||||
void tdm_reaper::print_group(std::string &id, const char* filename, bool include_meta, char sep)
|
||||
{
|
||||
// check for group id
|
||||
if ( this->tdmchannelgroups_.count(id) != 1 )
|
||||
@ -759,12 +759,22 @@ void tdm_reaper::print_group(std::string &id, const char* filename, bool include
|
||||
{
|
||||
if ( allchns.at(chi).size() > row )
|
||||
{
|
||||
fou<<std::setw(width)<<std::left<<allchns.at(chi).at(row);
|
||||
// use given csv separator token
|
||||
if ( sep == ' ' )
|
||||
{
|
||||
fou<<std::setw(width)<<std::left<<allchns.at(chi).at(row);
|
||||
}
|
||||
else
|
||||
{
|
||||
fou<<allchns.at(chi).at(row);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fou<<std::setw(width)<<std::left<<"";
|
||||
}
|
||||
|
||||
if ( chi+1 < chngrp.channels_.size() ) fou<<sep;
|
||||
}
|
||||
fou<<"\n";
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public:
|
||||
|
||||
// dump a single channel/entire group (identified by id) to file
|
||||
void print_channel(std::string &id, const char* filename, bool include_meta = true);
|
||||
void print_group(std::string &id, const char* filename, bool include_meta = true);
|
||||
void print_group(std::string &id, const char* filename, bool include_meta = true, char sep = ' ');
|
||||
|
||||
private:
|
||||
|
||||
|
16
src/main.cpp
16
src/main.cpp
@ -192,8 +192,16 @@ optkeys parse_args(int argc, char* argv[], bool showargs = false)
|
||||
{
|
||||
if ( argc > i+1 )
|
||||
{
|
||||
prsdkeys.insert(std::pair<std::string,std::string>("csvsep",argv[i+1]));
|
||||
i += 1;
|
||||
if ( std::string(argv[i+1]).size() == 1 )
|
||||
{
|
||||
prsdkeys.insert(std::pair<std::string,std::string>("csvsep",argv[i+1]));
|
||||
i += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr<<"invalid argument of --csvsep\n";
|
||||
prsdkeys.insert(std::pair<std::string,std::string>("invalidoption",argv[i+1]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -232,7 +240,7 @@ int main(int argc, char* argv[])
|
||||
optkeys cfgopts = parse_args(argc,argv);
|
||||
|
||||
// show all CLI arguments
|
||||
if ( false)
|
||||
if ( false )
|
||||
{
|
||||
for ( optkeys::iterator it=cfgopts.begin(); it!=cfgopts.end(); ++it )
|
||||
{
|
||||
@ -335,7 +343,7 @@ int main(int argc, char* argv[])
|
||||
std::filesystem::path outfile = pd / filenm;
|
||||
|
||||
// write entire channelgroup to file
|
||||
jack.print_group(id,outfile.c_str(),includemeta);
|
||||
jack.print_group(id,outfile.c_str(),includemeta,csvsep.at(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user