c++读取csv

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

using namespace std;
int main()
{

	ifstream fin("iData_ALL.csv"); //打开文件流操作
	string line;
	int i = 0;
	while (getline(fin, line))   //整行读取	
	{
		stringstream ss;
		ss << line;
		string partOfStr;
		for (int i = 0; i < 7; i++) //每行有七个数据
		{
			getline(ss, partOfStr, ',');
			cout << partOfStr << " ";


		}
		ss.clear();
		cout << endl;
	}
        return 0;
}
posted @ 2020-10-03 10:40  x66ccff  阅读(148)  评论(0)    收藏  举报