读取TSV文件(SQL Server或C#). [英] Reading TSV files(SQL Server OR C#).

查看:208
本文介绍了读取TSV文件(SQL Server或C#).的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我必须知道读取TSV文件的更好概念是什么?

在SQL Server中使用ODO JET 4.0连接字符串并从中读取文件

或使用C#代码读取TSV文件.

请建议我,这是更快更好,最可靠的方法(错误预测).

预先感谢.

Hi folks,

I have to know that which the better concept of reading TSV file is?

Using ODO JET 4.0 connection sting in SQL Server and reading files from that

Or Using C# code to reading TSV files.

Please suggest me that which is faster better and most reliable (error prediction).

Thanks in advance.

推荐答案

感谢GanesanSenthilvel

但是我有代码,我只需要知道哪个更好,更可靠.

在这种情况下,请帮助我.
Thanks, GanesanSenthilvel

But i have the code, i just need to know the which is faster better and most reliable.

Please help me in that case.


#include <fstream>
#include <string>
#include <vector>
using namespace std;

void ReadTSV(const char* filename)
{
using namespace std;

ifstream infile(filename);
if (!infile) {
cout << "unable to load file" << endl;
}
string str;

vector<vector<string> > vvStr;
vector<string> vStr;
int pos1, pos2;
while (getline(infile, str))
{
pos1 = 0;
while((pos2 = str.find('\t'))!= string::npos)
{
vStr.push_back(str.substr(pos1, pos2));
pos1 = pos2++;
}
vStr.push_back(str.substr(pos1, string::npos));
vvStr.push_back(vStr);
}

}


这篇关于读取TSV文件(SQL Server或C#).的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆