saveTable()

Output / Files

Description

Saves a Table to a CSV or TSV file.

Syntax

bool saveTable(std::string path, Table t, std::string ext)

Parameters

NameTypeDescription
pathstd::stringpath to write to
tTablethe table to save
extstd::string"csv" or "tsv" (default csv)

Returns

bool

Related

Under the Hood

From Processing.h:

static bool saveTable(const std::string& path, const Table& t, const std::string& ext="csv");

Under the Hood

From Processing.cpp:

bool PApplet::saveTable(const std::string& path,const Table& t,const std::string& ext){ std::ofstream f(path);if(!f)return false; char delim=ext=="tsv"?'\t':','; if(!t.columns.empty()){for(size_t i=0;i<t.columns.size();i++){if(i)f<<delim;f<<t.columns[i];}f<<"\n";} for(auto& row:t.rows){for(size_t i=0;i<row.size();i++){if(i)f<<delim;f<<row[i];}f<<"\n";} return true; }