I have the following code for reading an ascii file with 7 columns:
while (!in.atEnd())
{
in >> GratingType
>> newEntry.delay
>> newEntry.period
>> newEntry.phase
>> newEntry.chirp
>> newEntry.powerIndex
>> newEntry.powerScale;
VariationList.push_back(newEntry);
}
while (!in.atEnd())
{
in >> GratingType
>> newEntry.delay
>> newEntry.period
>> newEntry.phase
>> newEntry.chirp
>> newEntry.powerIndex
>> newEntry.powerScale;
VariationList.push_back(newEntry);
}
To copy to clipboard, switch view to plain text mode
However I also have files with a similar structure, but only 4 columns
while (!in.atEnd())
{
in >> GratingType
>> newEntry.delay
>> newEntry.period
>> newEntry.phase;
VariationList.push_back(newEntry);
}
while (!in.atEnd())
{
in >> GratingType
>> newEntry.delay
>> newEntry.period
>> newEntry.phase;
VariationList.push_back(newEntry);
}
To copy to clipboard, switch view to plain text mode
How can I find out how many columns my file has?
If I read a 4 column file with the 7 column version the data structure is read wrong.
This is a very basic question, and maybe not really Qt and more C++ related, but I do not really know how to start looking for a clever solution.
Bookmarks