Matrix program is very flexible and powerful for data manipulation. In this example, we will show how to convert CSV files into MAT files and vice versa. One can use this sample catalog to practice different CSV formats. Just replace the input file with your own file and modify some of part of the scripts. The purpose of this example is to help users to understand how PATTERN and FIELDS with different file structures.
The input CSV file contains trips data of this example is shown below:
The structure of the input file is I, J, M, V1, V2. We have two tables in the input file. So the first line means that from zone 1 to zone 1, there are 10 trips for MODE1 and 100 trips for MODE2.
So first, we convert the above trip file into OD matrix, refer to Matrix 1. The MAT file we get will looks below:
Next, we will convert the above MAT file back to CSV file with the original format. This will be done in Matrix 2.
Last, we will read the MAT file and output CSV file with MATRIX format for table 1(HOV) only in Matrix 3. The output CSV file will be the following:
You can download the catalog of this example in the attachment. The figure below illustrates its application process.
handleMATCVS.rar (15.1 KB)