@@ -431,7 +431,7 @@ namespace imc
431431 }
432432
433433 // print single specific channel
434- void print_channel (std::string channeluuid, std::string outputfile, const char sep)
434+ void print_channel (std::string channeluuid, std::string outputfile, const char sep, unsigned long int chunk_size = 100000 )
435435 {
436436 // check for given parent directory of output file
437437 std::filesystem::path pdf = outputfile;
@@ -444,7 +444,7 @@ namespace imc
444444 // find channel with given name
445445 if ( channels_.count (channeluuid) == 1 )
446446 {
447- channels_.at (channeluuid).print (outputfile,sep);
447+ channels_.at (channeluuid).print (outputfile,sep, 25 , 9 ,chunk_size );
448448 }
449449 else
450450 {
@@ -454,7 +454,7 @@ namespace imc
454454 }
455455
456456 // print all channels into given directory
457- void print_channels (std::string output, const char sep)
457+ void print_channels (std::string output, const char sep, unsigned long int chunk_size = 100000 )
458458 {
459459 // check for given directory
460460 std::filesystem::path pd = output;
@@ -474,7 +474,32 @@ namespace imc
474474 std::filesystem::path pf = pd / filenam;
475475
476476 // and print the channel
477- it->second .print (pf.u8string (),sep);
477+ it->second .print (pf.u8string (),sep,25 ,9 ,chunk_size);
478+ }
479+ }
480+
481+ // print all channels into given directory using streaming (memory-efficient)
482+ void print_channels_streaming (std::string output, const char sep, unsigned long int chunk_size = 100000 )
483+ {
484+ // check for given directory
485+ std::filesystem::path pd = output;
486+ if ( !std::filesystem::is_directory (pd) )
487+ {
488+ throw std::runtime_error (std::string (" given directory does not exist: " )
489+ + output);
490+ }
491+
492+ for ( std::map<std::string,imc::channel>::iterator it = channels_.begin ();
493+ it != channels_.end (); ++it)
494+ {
495+ // construct filename
496+ std::string chid = std::string (" channel_" ) + it->first ;
497+ std::string filenam = it->second .name_ .empty () ? chid + std::string (" .csv" )
498+ : it->second .name_ + std::string (" .csv" );
499+ std::filesystem::path pf = pd / filenam;
500+
501+ // and print the channel using streaming
502+ it->second .print (pf.u8string (),sep,25 ,9 ,chunk_size);
478503 }
479504 }
480505
0 commit comments