C++读取csv文件
            
            
                    
                        标签:space   iostream   命名   ack   number   file   back   field   cto   
C++读取csv文件,采用文件流的方法,用到了getline函数(带有自动分隔功能)
#include 
#include 
#include 
#include string>
#include using namespace std; //注意,命名空间 std
int main()
{
    ifstream infile("Test.csv");
    string line;
    getline(infile, line);
    while (getline(infile, line))
    {
        istringstream sin(line);
        vectorstring> fields;
        string field;
        while (getline(sin, field, ‘,‘)) 
        {
            fields.push_back(field);
        }
        string number = fields[0];
        string project_name = fields[1];
    }
}
 
 
C++读取csv文件
标签:space   iostream   命名   ack   number   file   back   field   cto   
原文地址:https://www.cnblogs.com/sbj123456789/p/13193709.html
                    
             
            
            
            
            
                
                    文章来自:
搜素材网的
编程语言模块,转载请注明文章出处。
                    文章标题:
C++读取csv文件
                    文章链接:http://soscw.com/index.php/essay/82569.html                
 
            
                                
评论