Commit e00113ef authored by Zhiping Jiang (蒋志平)'s avatar Zhiping Jiang (蒋志平) 💬

Add CSVFileWriter

parent 1854fd8b
......@@ -16,6 +16,7 @@
#include "jzplib_draw.h"
#include "jzplib_geom.h"
#include "jzplib_image.h"
#include "jzplib_utilities.h"
#include "jzplib_analysis.h"
// PoseSolverWrapper 3
......
//
// jzplib_utilities.cpp
// BinoCare
//
// Created by JiangZhping on 2017/3/22.
//
//
#include "jzplib_utilities.h"
#include <iomanip>
#include <fstream>
void CSVFileWriter::addCSVLine(std::vector<float> slot) {
slots.push_back(slot);
}
void CSVFileWriter::writeToFile(const std::string & filePath) {
std::ofstream textFile(filePath);
int i = 0, j =0 ;
for (i= 0; i< slots.size(); i++) {
for (j = 0; j < slots[i].size()-1; j++) {
textFile<<std::setprecision(10) <<slots[i][j]<<delimeter;
}
textFile<<std::setprecision(10) <<slots[i][j]<<std::endl;
}
textFile.flush();
textFile.close();
}
//
// jzplib_utilities.hpp
// BinoCare
//
// Created by JiangZhping on 2017/3/22.
//
//
#ifndef jzplib_utilities_h
#define jzplib_utilities_h
#include <string>
#include <vector>
class CSVFileWriter {
public:
std::string delimeter = " ";
void addCSVLine(std::vector<float> slot);
void writeToFile(const std::string & filePath);
private:
std::vector<std::vector<float>> slots;
};
#endif /* jzplib_utilities_h */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment