saveTable()
Output / FilesDescription
Saves a Table to a CSV or TSV file.
Syntax
bool saveTable(std::string path, Table t, std::string ext)
Parameters
| Name | Type | Description |
|---|---|---|
| path | std::string | path to write to |
| t | Table | the table to save |
| ext | std::string | "csv" or "tsv" (default csv) |
Returns
boolRelated
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;
}