Tcl Library Source Code

View Ticket
Login
Ticket UUID: 83a0b1b11bba28a29cf6be076c3c1943c8d958f5
Title: CSV lib and Struct Matrix packages
Type: Bug Version: TclLib 1.15 and TCL 8.4
Submitter: nikhilesh.saggere Created on: 2017-03-30 06:28:38
Subsystem: struct :: matrix Assigned To: aku
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2018-01-24 20:27:47
Resolution: By Design Closed By: aku
    Closed on: 2018-01-24 20:27:47
Description:
The API to get the number of rows in a CSV file always returns the maximum number of elements in any given row as the size.

Ex:
Consider the following as the content of the CSV file.
SYSTEM SIGNAL NUMBER VALUE 
R1     X      60     13
R2     Y      61     14     9   8   7

When the get row API is used to gets the content of the row in the current index, the entire content is returned as a list.

Considering the index is in the 2nd row, i.e, at X, the get row API returns list1 as
R1 X 60 13 followed by 3 spaces ({} {} {})

and when the index is at Y the get row api returns list2 as 
R2     Y      61     14     9   8   7

However the length of both the lists are now 7.
The length of the first list (list1) should it not be 4?

Please check.
User Comments: aku added on 2017-05-30 16:55:39:

This actually depends on how you created the matrix form the CSV file.

I suspect that you used read2matrix with the expand argument set to auto.

In this mode the reader automatically expands the matrix to fit the max number of columns found in the file.

You could try the other modes to see if they are more suitable.

Generally note that a matrix is a table, like in a database. Each row will have the same number of columns, even if some are empty. A matrix where each row has a different number of columns is not supported, and I do not intend to support that.

Does this help ?