The column count is known once you read the first record of the CSV file.
You can read the entire CSV file to determine a total row count. For a small file this is probably easiest.
Alternatively, implement a lazy fetching mechanism where you read rows in sets of up to n rows and return rowCount() of the number actually read to date. On open/reset the model reads up to n rows and rowCount() returns the number read. Implement canFetchMore() and fetchMore() to allow views to see the entire table if required. QSqlTableModel uses this approach with n == 256.
Bookmarks