obad
1st August 2010, 07:49
Hi ,
I have this code which is capable to read from file only one column , I need it read two column. So, how can I alter it to read from file and place the value in array ?
Note : the data file format like that :
10.2 30.3 12.4 ........
34.56 45.9 34.5.......
12.3 12.45 10.10.....
.
.
.
QTextStream in(&file);
unsigned int max_lines = 20000; // we choose 102 because in the real file there are two header lines in the top of file
float data[max_lines];
unsigned int lines_read =0;
for(int i=lines_read ;i<max_lines;i++)
{
double x;
QString content;
in >> x;
content = content.setNum(x);
data[i]=content.toDouble();
in.readLine();
lines_read++;
}
I have this code which is capable to read from file only one column , I need it read two column. So, how can I alter it to read from file and place the value in array ?
Note : the data file format like that :
10.2 30.3 12.4 ........
34.56 45.9 34.5.......
12.3 12.45 10.10.....
.
.
.
QTextStream in(&file);
unsigned int max_lines = 20000; // we choose 102 because in the real file there are two header lines in the top of file
float data[max_lines];
unsigned int lines_read =0;
for(int i=lines_read ;i<max_lines;i++)
{
double x;
QString content;
in >> x;
content = content.setNum(x);
data[i]=content.toDouble();
in.readLine();
lines_read++;
}