提交 16d15e28 编写于 作者: sahduashufa's avatar sahduashufa

add read_csv2.0

上级 f74e8f89
......@@ -87,3 +87,58 @@ Matrix read_csv(string &file_path)
}
return data_ma;
}
Matrix get_target(string &file_path)
{
int count_rows = 0,count_col = 0;
ifstream infile;
infile.open(file_path);
while(!infile.eof())
{
count_col = 0;
count_rows+=1;
infile >> data;
int iSize = data.size();
int flag_if = 1;
for(int i = 0;i < iSize; i++)
{
if(data[i]==',')
{
count_col++;
}
}
}
Matrix data_ma = CreateMatrix(count_rows+1,count_col+1);
ifstream infile2;
infile2.open(file_path);
int next_flag = 0;
while(!infile2.eof())
{
next_flag+=1;
infile2 >> data;
string base = "";
string added ="";
int iSize = data.size();
int flag_if = 1;
int count_times = 0;
cout<<iSize<<endl;
for(int i = 0;i < iSize; i++)
{
if(data[i]!=',')
{
added+=data[i];
}
else if(data[i]==',')
{
count_times+=1;
base = added;
char *result = (char*)base.data();
cout<<"result: "<<result<<endl;
data_ma.matrix[next_flag][count_times-1] = str2double(result);
added ="";
base = "";
}
}
}
return data_ma;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册