parent
c786cc5783
commit
5757bd1504
@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef CSVREADER_H
|
||||||
|
#define CSVREADER_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
// 定义一个结构体来存储CSV文件的每一行数据
|
||||||
|
struct CSVRow {
|
||||||
|
vector<string> data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 读取CSV文件的类
|
||||||
|
class CSVReader {
|
||||||
|
private:
|
||||||
|
string filename;
|
||||||
|
ifstream file;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CSVReader(const string& filename); // 构造函数
|
||||||
|
~CSVReader(); // 析构函数
|
||||||
|
|
||||||
|
vector<CSVRow> readByLine(); // 按行读取
|
||||||
|
vector<CSVRow> readByBlock(int blockSize); // 按块读取
|
||||||
|
string readByByte(int byteSize); // 按字节读取
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CSVREADER_H
|
Loading…
Reference in new issue