Unnatural to read in data files line by line
Filestreams allow us to iterate over the lines of a file. When we split
the line, e.g. by a comma or space, the usual thing is to add this
resulting vector to another container.
The result might be a Vector< Vector<String> > (or your flavor of
containers).
When I give this to a QTableView using a QAbstractTableModel, the rows and
columns are inverted: the outer container actually denotes the rows, while
the inner container denotes columns.
I am unsure what to do, since I want to present the data, allow some
editing actions (editing the model), and then write it out into a
comparable file.
My data will be around 200,000 rows (people) by 300 columns (values), and
it is actually slower to read into the vector from file, but faster to
present in the QTableView when I read the matrix in an inverted way. When
writing it to another file, it is not so easy this time to write out a
transposed vector compared to the normal way in which you can just:
for (int iter = 0; ....; ...)
{
row = matrix[iter].join(" ")
file.write(row)
}
Am I missing something obvious? It has to be displayed in the inverted
way. When connecting the model to the view should I transpose, or should I
fill the matrix originally in an inverted way?
No comments:
Post a Comment