C++ 解析 csv 方法对比

本文比较了多种C++解析CSV文件的方法,包括使用Boost.Tokenizer、STL以及各种开源库。通过性能和稳定性方面的考量,探讨了不同方法的优缺点,并提供了相关的参考资料链接,以供进一步研究和选择合适的CSV解析方案。
摘要由CSDN通过智能技术生成

1.Parse csv file with boost tokenizer in C++

参考网址:http://mybyteofcode.blogspot.com/2010/02/parse-csv-file-with-boost-tokenizer-in.html  请自动翻

include <iostream>     // cout, endl
#include <fstream>      // fstream
#include <vector>
#include <string>
#include <algorithm>    // copy
#include <iterator>     // ostream_operator

#include <boost/tokenizer.hpp>

int main()
{
    using namespace std;
    using namespace boost;

    string data("data.csv");

    ifstream in(data.c_str());
    if (!in.is_open()) return 1;

    typedef tokenizer< escaped_list_separator<char> > Tokenizer;

    vector< string > vec;
    string line;

    while (getline(in,line))
    {
        Tokenizer tok(line);
        vec.assign(tok.begin(),tok.end());

        if (vec.size() < 3) continue;

        copy(vec.begin(), vec.end(),
             ostream_iterator<string>(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值