C++ Code Examples for write csv

34 C++ code examples are found related to "write csv". These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Example 1
Project: ORB_SLAM2_Android   Author: FangGet   File: property.cpp    License: GNU General Public License v3.0 6 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 2
Project: feature-dso-stereo   Author: renjingc   File: property.cpp    License: GNU General Public License v3.0 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 3
Project: Phore-old   Author: phoreproject   File: csvmodelwriter.cpp    License: MIT License 5 votes vote down vote up
bool CSVModelWriter::write()
{
    QFile file(filename);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream out(&file);

    int numRows = 0;
    if (model) {
        numRows = model->rowCount();
    }

    // Header row
    for (int i = 0; i < columns.size(); ++i) {
        if (i != 0) {
            writeSep(out);
        }
        writeValue(out, columns[i].title);
    }
    writeNewline(out);

    // Data rows
    for (int j = 0; j < numRows; ++j) {
        for (int i = 0; i < columns.size(); ++i) {
            if (i != 0) {
                writeSep(out);
            }
            QVariant data = model->index(j, columns[i].column).data(columns[i].role);
            writeValue(out, data.toString());
        }
        writeNewline(out);
    }

    file.close();

    return file.error() == QFile::NoError;
} 
Example 4
Project: rosbag2   Author: ros2   File: benchmark.cpp    License: Apache License 2.0 5 votes vote down vote up
void ros2bag::write_csv_file(
  std::string const & file_name, Benchmark const & benchmark, bool with_header)
{
  std::ofstream file;
  if (with_header) {
    std::remove(file_name.c_str());
  }
  file.open(file_name, std::ofstream::out | std::ofstream::app);
  benchmark.write_csv(file, with_header);
  file.close();
} 
Example 5
Project: lux   Author: LUX-Core   File: csvmodelwriter.cpp    License: GNU Affero General Public License v3.0 5 votes vote down vote up
bool CSVModelWriter::write()
{
    QFile file(filename);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream out(&file);

    int numRows = 0;
    if (model) {
        numRows = model->rowCount();
    }

    // Header row
    for (int i = 0; i < columns.size(); ++i) {
        if (i != 0) {
            writeSep(out);
        }
        writeValue(out, columns[i].title);
    }
    writeNewline(out);

    // Data rows
    for (int j = 0; j < numRows; ++j) {
        for (int i = 0; i < columns.size(); ++i) {
            if (i != 0) {
                writeSep(out);
            }
            QVariant data = model->index(j, columns[i].column).data(columns[i].role);
            writeValue(out, data.toString());
        }
        writeNewline(out);
    }

    file.close();

    return file.error() == QFile::NoError;
} 
Example 6
Project: GAAS   Author: generalized-intelligence   File: property.cpp    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 7
Project: Semantic_SLAM   Author: 1989Ryan   File: property.cpp    License: MIT License 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 8
Project: fast-xnor-net   Author: gokul-uf   File: pcm-memory.cpp    License: GNU General Public License v3.0 5 votes vote down vote up
void display_bandwidth_csv_header(float *iMC_Rd_socket_chan, float *iMC_Wr_socket_chan, float *iMC_Rd_socket, float *iMC_Wr_socket, uint32 numSockets, uint32 num_imc_channels, uint64 *partial_write)
{
  cout << ";;" ; // Time

    for (uint32 skt=0; skt < numSockets; ++skt)
    {
      for(uint64 channel = 0; channel < num_imc_channels; ++channel)
	{
	  if(iMC_Rd_socket_chan[skt*num_imc_channels+channel] < 0.0 && iMC_Wr_socket_chan[skt*num_imc_channels+channel] < 0.0) //If the channel read neg. value, the channel is not working; skip it.
	    continue;
	  cout << "SKT" << skt << ";SKT" << skt << ';';
	}
      cout << "SKT"<<skt<<";"
	   << "SKT"<<skt<<";"
	   << "SKT"<<skt<<";"
	   << "SKT"<<skt<<";";
      
    }
    cout << "System;System;System\n";
      

  cout << "Date;Time;" ;
    for (uint32 skt=0; skt < numSockets; ++skt)
    {
      for(uint64 channel = 0; channel < num_imc_channels; ++channel)
	{
	  if(iMC_Rd_socket_chan[skt*num_imc_channels+channel] < 0.0 && iMC_Wr_socket_chan[skt*num_imc_channels+channel] < 0.0) //If the channel read neg. value, the channel is not working; skip it.
	    continue;
	  cout << "Ch" <<channel <<"Read;"
	       << "Ch" <<channel <<"Write;";
	}
      cout << "Mem Read (MB/s);Mem Write (MB/s); P. Write (T/s); Memory (MB/s);";
    }

    cout << "Read;Write;Memory" << endl;
} 
Example 9
Project: fast-xnor-net   Author: gokul-uf   File: pcm-memory.cpp    License: GNU General Public License v3.0 5 votes vote down vote up
void display_bandwidth_csv(float *iMC_Rd_socket_chan, float *iMC_Wr_socket_chan, float *iMC_Rd_socket, float *iMC_Wr_socket, uint32 numSockets, uint32 num_imc_channels, uint64 *partial_write, uint64 elapsedTime)
{
    time_t t = time(NULL);
    tm *tt = localtime(&t);
    cout.precision(3);
    cout << 1900+tt->tm_year << '-' << 1+tt->tm_mon << '-' << tt->tm_mday << ';'
         << tt->tm_hour << ':' << tt->tm_min << ':' << tt->tm_sec << ';';


    float sysRead = 0.0, sysWrite = 0.0;

    cout.setf(ios::fixed);
    cout.precision(2);

    for (uint32 skt=0; skt < numSockets; ++skt)
     {
       for(uint64 channel = 0; channel < num_imc_channels; ++channel)
	 {
	   if(iMC_Rd_socket_chan[skt*num_imc_channels+channel] < 0.0 && iMC_Wr_socket_chan[skt*num_imc_channels+channel] < 0.0) //If the channel read neg. value, the channel is not working; skip it.
	     continue;
	   cout <<setw(8) <<iMC_Rd_socket_chan[skt*num_imc_channels+channel] << ';'
		<<setw(8) <<iMC_Wr_socket_chan[skt*num_imc_channels+channel] << ';';
	   
	 }
       cout <<setw(8) <<iMC_Rd_socket[skt] <<';'
            <<setw(8) <<iMC_Wr_socket[skt] <<';'
            <<setw(10) <<dec<<partial_write[skt] <<';'
            <<setw(8) <<iMC_Rd_socket[skt]+iMC_Wr_socket[skt] <<';';

            sysRead += iMC_Rd_socket[skt];
            sysWrite += iMC_Wr_socket[skt];
    }

    cout <<setw(10) <<sysRead <<';'
	 <<setw(10) <<sysWrite <<';'
	 <<setw(10) <<sysRead+sysWrite << endl;
} 
Example 10
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
_Use_decl_annotations_
    void CsvWriter::WriteComma(
        bool* writeComma)
    {
        if (*writeComma)
        {
            _file << ',';
        }
        else
        { 
Example 11
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
_Use_decl_annotations_
    void CsvWriter::WriteFloat4x4(
        const Windows::Foundation::Numerics::float4x4& value,
        bool* writeComma)
    {
        WriteFloat(value.m11, writeComma);
        WriteFloat(value.m12, writeComma);
        WriteFloat(value.m13, writeComma);
        WriteFloat(value.m14, writeComma);

        WriteFloat(value.m21, writeComma);
        WriteFloat(value.m22, writeComma);
        WriteFloat(value.m23, writeComma);
        WriteFloat(value.m24, writeComma);

        WriteFloat(value.m31, writeComma);
        WriteFloat(value.m32, writeComma);
        WriteFloat(value.m33, writeComma);
        WriteFloat(value.m34, writeComma);

        WriteFloat(value.m41, writeComma);
        WriteFloat(value.m42, writeComma);
        WriteFloat(value.m43, writeComma);
        WriteFloat(value.m44, writeComma);
    } 
Example 12
Project: trittium   Author: Trittium   File: csvmodelwriter.cpp    License: MIT License 5 votes vote down vote up
bool CSVModelWriter::write()
{
    QFile file(filename);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream out(&file);

    int numRows = 0;
    if (model) {
        numRows = model->rowCount();
    }

    // Header row
    for (int i = 0; i < columns.size(); ++i) {
        if (i != 0) {
            writeSep(out);
        }
        writeValue(out, columns[i].title);
    }
    writeNewline(out);

    // Data rows
    for (int j = 0; j < numRows; ++j) {
        for (int i = 0; i < columns.size(); ++i) {
            if (i != 0) {
                writeSep(out);
            }
            QVariant data = model->index(j, columns[i].column).data(columns[i].role);
            writeValue(out, data.toString());
        }
        writeNewline(out);
    }

    file.close();

    return file.error() == QFile::NoError;
} 
Example 13
Project: OpenREALM   Author: laxnpander   File: property.cpp    License: GNU General Public License v3.0 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 14
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
_Use_decl_annotations_
    void CsvWriter::WriteFloat(
        const float value,
        bool* writeComma)
    {
        WriteComma(
            writeComma);

        _file << value;
    } 
Example 15
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
_Use_decl_annotations_
    void CsvWriter::WriteDouble(
        const double value,
        bool* writeComma)
    {
        WriteComma(
            writeComma);

        _file << value;
    } 
Example 16
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
_Use_decl_annotations_
    void CsvWriter::WriteQuaternionWXYZ(
        const Windows::Foundation::Numerics::quaternion& value,
        bool* writeComma)
    {
        WriteFloat(value.w, writeComma);
        WriteFloat(value.x, writeComma);
        WriteFloat(value.y, writeComma);
        WriteFloat(value.z, writeComma);
    } 
Example 17
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
void CsvWriter::WriteZeroFloat4x4(
        _Inout_ bool* writeComma)
    {
        for (int32_t i = 0; i < 16; ++i)
        {
            WriteFloat(0.0f, writeComma);
        }
    } 
Example 18
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
_Use_decl_annotations_
    void CsvWriter::WriteFloat3XYZ(
        const Windows::Foundation::Numerics::float3& value,
        bool* writeComma)
    {
        WriteFloat(value.x, writeComma);
        WriteFloat(value.y, writeComma);
        WriteFloat(value.z, writeComma);
    } 
Example 19
Project: ygz-stereo-inertial   Author: gaoxiang12   File: property.cpp    License: MIT License 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 20
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
_Use_decl_annotations_
    void CsvWriter::WriteText(
        const std::wstring& text,
        bool* writeComma)
    {
        WriteComma(
            writeComma);

        _file << text;
    } 
Example 21
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
_Use_decl_annotations_
    void CsvWriter::WriteUInt64(
        _In_ const uint64_t value,
        _Inout_ bool* writeComma)
    {
        WriteComma(
            writeComma);

        _file << value;
    } 
Example 22
Project: brainflow   Author: brainflow-dev   File: brainflow_get_data.cpp    License: MIT License 5 votes vote down vote up
void write_csv (const char *filename, double **data_buf, int data_count, int total_channels)
{
    ofstream output_file;
    output_file.open (filename);
    for (int i = 0; i < data_count; i++)
    {
        for (int j = 0; j < total_channels; j++)
        {
            output_file << data_buf[i][j] << ",";
        }
        output_file << endl;
    }
    output_file.close ();
} 
Example 23
Project: HoloLensForCV   Author: microsoft   File: CsvWriter.cpp    License: MIT License 5 votes vote down vote up
_Use_decl_annotations_
    void CsvWriter::WriteInt32(
        const int32_t value,
        bool* writeComma)
    {
        WriteComma(
            writeComma);

        _file << value;
    } 
Example 24
Project: duckdb   Author: cwida   File: write_csv_relation.cpp    License: MIT License 5 votes vote down vote up
BoundStatement WriteCSVRelation::Bind(Binder &binder) {
	CopyStatement copy;
	copy.select_statement = child->GetQueryNode();
	auto info = make_unique<CopyInfo>();
	info->is_from = false;
	info->file_path = csv_file;
	copy.info = move(info);
	return binder.Bind((SQLStatement &)copy);
} 
Example 25
Project: StructSLAM   Author: x007dwd   File: property.cpp    License: MIT License 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 26
Project: CondominiumCore   Author: condominium   File: csvmodelwriter.cpp    License: MIT License 5 votes vote down vote up
bool CSVModelWriter::write()
{
    QFile file(filename);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream out(&file);

    int numRows = 0;
    if (model) {
        numRows = model->rowCount();
    }

    // Header row
    for (int i = 0; i < columns.size(); ++i) {
        if (i != 0) {
            writeSep(out);
        }
        writeValue(out, columns[i].title);
    }
    writeNewline(out);

    // Data rows
    for (int j = 0; j < numRows; ++j) {
        for (int i = 0; i < columns.size(); ++i) {
            if (i != 0) {
                writeSep(out);
            }
            QVariant data = model->index(j, columns[i].column).data(columns[i].role);
            writeValue(out, data.toString());
        }
        writeNewline(out);
    }

    file.close();

    return file.error() == QFile::NoError;
} 
Example 27
Project: IndoorMapping   Author: was48i   File: property.cpp    License: Apache License 2.0 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 28
Project: LCSD_SLAM   Author: sunghoon031   File: property.cpp    License: GNU General Public License v3.0 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 29
Project: transcendence   Author: phoenixkonsole   File: csvmodelwriter.cpp    License: MIT License 5 votes vote down vote up
bool CSVModelWriter::write()
{
    QFile file(filename);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream out(&file);

    int numRows = 0;
    if (model) {
        numRows = model->rowCount();
    }

    // Header row
    for (int i = 0; i < columns.size(); ++i) {
        if (i != 0) {
            writeSep(out);
        }
        writeValue(out, columns[i].title);
    }
    writeNewline(out);

    // Data rows
    for (int j = 0; j < numRows; ++j) {
        for (int i = 0; i < columns.size(); ++i) {
            if (i != 0) {
                writeSep(out);
            }
            QVariant data = model->index(j, columns[i].column).data(columns[i].role);
            writeValue(out, data.toString());
        }
        writeNewline(out);
    }

    file.close();

    return file.error() == QFile::NoError;
} 
Example 30
Project: mulberryAR   Author: polobymulberry   File: property.cpp    License: MIT License 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 31
Project: openslam   Author: yueying   File: property.cpp    License: GNU General Public License v3.0 5 votes vote down vote up
void PropertyMap::writeToCSV(std::ostream& os) const
  {
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->name() << ", ";
    }
    os << std::endl;
    for (PropertyMapConstIterator it=begin(); it!=end(); it++){
      BaseProperty* p =it->second;
      os << p->toString() << ", ";
    }
    os << std::endl;
  } 
Example 32
Project: Electra   Author: electra01   File: csvmodelwriter.cpp    License: MIT License 4 votes vote down vote up
bool CSVModelWriter::write()
{
    QFile file(filename);
    if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream out(&file);

    int numRows = 0;
    if(model)
    {
        numRows = model->rowCount();
    }

    // Header row
    for(int i=0; i<columns.size(); ++i)
    {
        if(i!=0)
        {
            writeSep(out);
        }
        writeValue(out, columns[i].title);
    }
    writeNewline(out);

    // Data rows
    for(int j=0; j<numRows; ++j)
    {
        for(int i=0; i<columns.size(); ++i)
        {
            if(i!=0)
            {
                writeSep(out);
            }
            QVariant data = model->index(j, columns[i].column).data(columns[i].role);
            writeValue(out, data.toString());
        }
        writeNewline(out);
    }

    file.close();

    return file.error() == QFile::NoError;
} 
Example 33
Project: verge   Author: vergecurrency   File: csvmodelwriter.cpp    License: MIT License 4 votes vote down vote up
bool CSVModelWriter::write()
{
    QFile file(filename);
    if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream out(&file);

    int numRows = 0;
    if(model)
    {
        numRows = model->rowCount();
    }

    // Header row
    for(int i=0; i<columns.size(); ++i)
    {
        if(i!=0)
        {
            writeSep(out);
        }
        writeValue(out, columns[i].title);
    }
    writeNewline(out);

    // Data rows
    for(int j=0; j<numRows; ++j)
    {
        for(int i=0; i<columns.size(); ++i)
        {
            if(i!=0)
            {
                writeSep(out);
            }
            QVariant data = model->index(j, columns[i].column).data(columns[i].role);
            writeValue(out, data.toString());
        }
        writeNewline(out);
    }

    file.close();

    return file.error() == QFile::NoError;
} 
Example 34
Project: SanDeGo   Author: SanDeGoProject   File: csvmodelwriter.cpp    License: MIT License 4 votes vote down vote up
bool CSVModelWriter::write()
{
    QFile file(filename);
    if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
        return false;
    QTextStream out(&file);

    int numRows = 0;
    if(model)
    {
        numRows = model->rowCount();
    }

    // Header row
    for(int i=0; i<columns.size(); ++i)
    {
        if(i!=0)
        {
            writeSep(out);
        }
        writeValue(out, columns[i].title);
    }
    writeNewline(out);

    // Data rows
    for(int j=0; j<numRows; ++j)
    {
        for(int i=0; i<columns.size(); ++i)
        {
            if(i!=0)
            {
                writeSep(out);
            }
            QVariant data = model->index(j, columns[i].column).data(columns[i].role);
            writeValue(out, data.toString());
        }
        writeNewline(out);
    }

    file.close();

    return file.error() == QFile::NoError;
}