4

Is there a way to read a TransCad Matrix file (mtx) without access to Transcad.

I am trying to convert a matrix file to a csv file.

1

If you have TransCAD, you can use the Caliper Python module that lets you access TransCAD and it's programming language GISDK via a program written in Python. With it, you can write a Python program like the one below:

import sys, traceback, caliper    

dk = caliper.Gisdk("TransCAD")    
rh = dk.GetFirstRecord(view_set)    
for row in dk.GetRecordsValues(view_set,rh,field_names,sort_order,num_found,order,None):
    print str(row)

In terms of matrix handling, there are functions that allow you to export TransCAD matrices into CSV:

folder = dk.apply("G30 Tutorial Folder","gis_ui")    
m = dk.OpenMatrix(folder + "OD.mtx",None)    
CreateTableFromMatrix(m, folder + "myimp.csv", "CSV", {{"Complete", "Yes"}})

You can go into Help-TransCAD in the TransCAD menu, click on the Index tab and type in Python for more info on setting up Python for TransCAD. You can also type in any function name (e.g. CreateTableFromMatrix()) for more specific information on any GISDK function.

Regards, Jim

Jim Lam

Caliper Corporation

www.caliper.com

  • I would normally edit out a signature, but in this case it discloses your association with the company you are discussing (which is good)...in the future, just say it in your post instead. – Evil Genius Jan 19 '16 at 14:57
  • Thank you but I didn't mention that I do not have access to Transcad. – aconti74 Jan 20 '16 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.