22 #include "../scheduling/Clock.h"
23 #include "../utility/cnpy.hpp"
59 ,
const string& outputFormat
60 ,
const string& openmode
61 ,
const vector<double>& data
62 ,
const vector<string>& columns
65 if( data.size() == 0 )
68 if(
"npy" == outputFormat )
70 else if(
"csv" == outputFormat or
"dat" == outputFormat )
75 <<
". Use npy or csv. Falling back to default csv"
84 ,
const vector<double>& data,
const vector<string>& columns )
87 FILE* fp = fopen( filepath.c_str(), openmode.c_str() );
97 string headerText =
"";
98 for( vector<string>::const_iterator it = columns.begin();
99 it != columns.end(); it++ )
102 fprintf( fp,
"%s", headerText.c_str() );
106 for(
size_t i = 0; i < data.size(); i+=columns.size() )
109 for(
size_t ii = 0; ii < columns.size(); ii++ )
113 *(text.end()-1) =
eol;
115 fprintf( fp,
"%s", text.c_str() );
121 ,
const vector<double>& data,
const vector<string>& columns )
123 cnpy2::save_numpy<double>( filepath,
data, columns, openmode );
string toString(double x)
Convert a given value to string.
static void writeToNPYFile(const string &filepath, const string &openmode, const vector< double > &data, const vector< string > &columns)
Write to NPY format. See the documentation of writeToOutfile for more details.
StreamerBase & operator=(const StreamerBase &st)
const vector< double > & data()
#define LOG(t, a)
This macro only expands when not compiling for release.
static const char delimiter_
static void writeToCSVFile(const string &filepath, const string &openmode, const vector< double > &data, const vector< string > &columns)
Write data to csv file. See the documentation of writeToOutfile for details.
static void writeToOutFile(const string &filepath, const string &format, const string &openmode, const vector< double > &data, const vector< string > &columns)
Write to a output file in given format.
void setOutFilepath(string stream)
string getOutFilepath() const