You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
656 B
33 lines
656 B
#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
|