将.csv文件转换为C++;算法 我想把一个.CSV文件读入一个C++代码中,然后把文本数据转换成一个结构。我可以编写一个算法来读取.csv文件,但如何将其保存到结构中。。csv文件中的数据位于excel单元格中。第一列包含纬度,第二列包含经度,第三列包含分支代码,第四列包含地址,共有7000行包含不同的位置和地址。。在C++算法中,需要将这些结构保存为一个结构。 #include <iostream> #include <fstream> #include <string> using namespace std; int main () { string line; ofstream myfile; myfile.open("burgerking.csv"); if(myfile.is_open()){ cout<<"The file is open"<<endl; while (getline(myfile,line)) { cout << line << '\n'; } } myfile.close(); system("PAUSE"); return 0; } #包括 #包括 #包括 使用名称空间std; int main(){ 弦线; 流文件; myfile.open(“burgerking.csv”); 如果(myfile.is_open()){ cout
存储互连结构的一种(好)方法是使用索引: 您不能/不应该将内存地址0x12345678处的结构写入文件将.csv文件转换为C++;算法 我想把一个.CSV文件读入一个C++代码中,然后把文本数据转换成一个结构。我可以编写一个算法来读取.csv文件,但如何将其保存到结构中。。csv文件中的数据位于excel单元格中。第一列包含纬度,第二列包含经度,第三列包含分支代码,第四列包含地址,共有7000行包含不同的位置和地址。。在C++算法中,需要将这些结构保存为一个结构。 #include <iostream> #include <fstream> #include <string> using namespace std; int main () { string line; ofstream myfile; myfile.open("burgerking.csv"); if(myfile.is_open()){ cout<<"The file is open"<<endl; while (getline(myfile,line)) { cout << line << '\n'; } } myfile.close(); system("PAUSE"); return 0; } #包括 #包括 #包括 使用名称空间std; int main(){ 弦线; 流文件; myfile.open(“burgerking.csv”); 如果(myfile.is_open()){ cout,c++,algorithm,structure,C++,Algorithm,Structure,存储互连结构的一种(好)方法是使用索引: 您不能/不应该将内存地址0x12345678处的结构写入文件,但您可以写入这是结构181,它的第一个引用指向结构912,第二个引用指向… 这可以有效地完成:拥有一个hashmap,将结构指针映射到您为其选择的索引,每次编写指针时,您都要编写索引。\include #include <iostream> #include <sstream> #include <fstream> #include <vector
,但您可以写入这是结构181,它的第一个引用指向结构912,第二个引用指向…
这可以有效地完成:拥有一个hashmap,将结构指针映射到您为其选择的索引,每次编写指针时,您都要编写索引。\include
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
#include <string.h>
#include "link1.h"
using namespace std;
class struc{
link1 l1;
public:
struc()
{
string lat,lon, addr;
string state1="\0";
string state;
l1.link1();
ifstream inFile ("burgerking.csv");
string line;
int linenum = 0;
while (getline (inFile, line))
{
linenum++;
cout << "\nLine #" << linenum << ":" << endl;
istringstream linestream(line);
string item;
int itemnum = 0;
while (getline (linestream, item, ','))
{
lat=item;
break;}
while (getline (linestream, item, ','))
{
lon=item;
break;
}
while (getline (linestream, item, ','))
{
addr=item;
break;
}
while (getline (linestream, item, ','))
{
state=item;
break;
// cout<<lat<<endl<<lon<<endl<<addr<<endl<<state<<endl;
}
if(state1==state)
break;
else
l1.add(state);
state1=state;
}
}
void disp()
{
l1.display();
}};
////// Hey man please contact me ASAP skype:mrwaleedahmed i have got the same task as a project so need a little bit of help
#包括
#包括
#包括
#包括
#包括“link1.h”
使用名称空间std;
类结构{
链接1 l1;
公众:
struc()
{
字符串lat、lon、addr;
字符串state1=“\0”;
字符串状态;
l1.link1();
ifstream INFLE(“burgerking.csv”);
弦线;
int linenum=0;
while(getline(infle,line))
{
linenum++;
你将如何拯救它有人推测,应该非常小心。你写过代码吗?你知道你需要什么样的数据结构吗?你到底在哪里卡住了?你不想用中的地址序列化结构。每次重新运行代码时,地址都会包含不同的内容。除非他指的是Excel中的单元格地址(A1,B1,C1…)。老实说,这不是一个很清楚的问题。可能是重复的我只是试图读取文件,但getline函数中有错误我不知道为什么…这是一个.csv文件我认为这应该是问题什么是“link1.h”
。?如果您想将数据移动到一个链接列表中,我必须像project那样做,我自己也被卡住了