我正在尝试使用C ++读取CSV文件并进行计算,然后将结果输出到另一个CSV文件。一切都很顺利,但当程序读取一行时:
<a href="http://www.google.com" target="_blank">google</a>
我希望能够查看程序读取的内容,因此我输出了该字符串,结果显示:
<a href=""http://www.google.com"" target=""_blank"">google</a>
基本上它会将每个双引号都加倍?那我该怎么解决呢?
编辑:
这是我的代码:
int main()
{
ifstream read;
ofstream write;
string line;
string cell;
int col = 0;
string temp;
string links;
read.open("Book1.csv");
write.open("output.csv");
if (read.is_open())
{
cout << "opened" <<endl ;
getline(read, line);
while(getline(read,temp))
{
stringstream line(temp);
while (getline(line, cell, ','))
{
if (col > 9)
{
links.pop_back();
write << links<<endl;
col = 0;
links = "";
break;
}
else
{
if (cell != "")
{
if (col == 0)
{
write << cell<<',';
}
else if (col == 1)
{
write << cell<<',';
}
else
{
cell.erase(0, 1);
cell.pop_back();
links += cell;
links += '/';
}
cout << cell << endl;
}
col += 1;
}
}
}
}
else
{
cout << "failed" << endl;
}
read.close();
write.close();
}