
Introduction MassMotion's timetables are incredibly powerful, but can be time-consuming to pull together by hand. On the other hand, simple programs can do much of the donkey work, converting files such as Origin/Destination Matrices (OD Matrices) or train schedules into a form that MassMotion can read. In this article I will be looking at converting an OD Matrix into a timetable schedule file using a programming language called Python.
Python Python is a free scripting language that is simple to use, powerful, and importantly for us great for working with comma separated value (.csv) files, which are a typical output from Excel.
Python comes in two slightly different versions: Python2x and Python3x. The x refers to the particular build: I am currently using Python3.4.3. You may find a certain amount of controversy online regarding which it is best to use, as Python3x cannot read libraries written in 2x. This is mostly academic now, as over the last few years the majority of libraries have now been updated. My recommendation is that you should use Python3x, and only use Python2x if you have a definite need to work with legacy systems.
You can download the main version of Python from www.python.org, including the IDLE shell, which is a programming environment aimed to help you write and run the programs. There are other Python shells out there out there that might offer some advantages to you, and there will be lots of online discussions extoling the various merits of each. You can even write your scripts in Notepad or Notepad++ and run them with a Windows command line if you wish.
Coding with Python There is lots of guidance available on how to write Python programs, including much which is free on the web (https://docs.python.org/3/tutorial/ is a good place to start). Here I will go through a few key points, but I do recommend that you do one of the many excellent courses or books that are out there.
If you are used to programming in other languages, you may note that a main difference between it and other languages is that loops and other relationships are shown by indenting. For example, a FOR/NEXT loop does not include a NEXT, but instead looks something like this:
for row in input_file: input_rows.append(row) Comments always start with a #, so Python will ignore anything you write after one.
Rather than creating Arrays, Python uses Lists, and allows an item in a List to also be a List. In the script below I create a List, where each item is a line from the OD matrix csv. As items in a List are separated by commas, each line becomes its own list, allowing me to pluck individual values out. For example, to retrieve the value from the second column in the third row of the csv I might ask for (as Python always has the first item as zero):
row[2][1] While Python has many commands that you can use, there are modules and libraries available to make your life easier. In our case, we will import the csv module, which enables us to read and write such files without having to do so much coding. We do this with:
import csv Commands using this module start with csv. , such as csv.reader and csv.writer.
Note that for a general program you might want to add in browse dialogs to grab the files and locations, but for something like this I suggest that you just edit the names directly into the script and save the script into the same folder as the files you want to work on.
The Data For this exercise I have created a very simple OD matrix, but the program will work with one of any size:
OD Matrix ExitPortal1 ExitPortal2 ExitPortal3 ExitPortal4 ExitPortal5 ExitPortal6 ExitPortal7
EntryPortal1 0 80 51 0 19 81 7
EntryPortal2 51 10 70 40 110 0 12
EntryPortal3 99 26 20 47 58 39 3
EntryPortal4 39 16 119 0 5 4 75
EntryPortal5 11 44 0 35 10 108 0
EntryPortal6 0 1 115 77 0 21 47
And the end result will look like this:
From To Population Time offset Curve Avatar Profile Init Action Give Tokens
EntryPortal1 ExitPortal2 80 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1
EntryPortal1 ExitPortal3 51 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1
EntryPortal1 ExitPortal5 19 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1
EntryPortal1 ExitPortal6 81 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1
EntryPortal1 ExitPortal7 7 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1
EntryPortal2 ExitPortal1 51 00:00:00 Arrival_curve Orange_LowPoly DefaultProfile Action1 Token1
I have only shown the first few lines, just enough to show how it works. The end result has one line per non-zero value in the OD matrix plus the headers. Some items are optional, so for example you might leave the Action column blank if you are not applying any to the agents when they spawn.
As these are csv files the OD matrix (OD_matrix.csv) actually looks like this:
OD Matrix,ExitPortal1,ExitPortal2,ExitPortal3,ExitPortal4,ExitPortal5,ExitPortal6,ExitPortal7 EntryPortal1,0,80,51,0,19,81,7 EntryPortal2,51,10,70,40,110,0,12 EntryPortal3,99,26,20,47,58,39,3 EntryPortal4,39,16,119,0,5,4,75 EntryPortal5,11,44,0,35,10,108,0 EntryPortal6,0,1,115,77,0,21,47 And the results look similar.
The program As you will see, the resultant Python script (OD-schedule.py) is not long and hopefully easy to follow.
# OD matrix to MassMotion Timetable # read OD matrix csv and write Schedule csv import csv # enable the use of csv commands # set up standard values - adjust to suit: offset = 00:00:00 # from start of simulation for start of arrivals (optional) curve = Arrival_curve # defined in Timetable_curve.csv (optional) avatar = Orange_LowPoly # defaul
Most recent headlines
05/01/2027
Worlds first 802.15.4ab-UWB chip verified by Calterah and Rohde & Schwarz to be ...
01/06/2026
January 6 2026, 05:30 (PST) Dolby Sets the New Standard for Premium Entertainment at CES 2026
Throughout the week, Dolby brings to life the latest innovatio...
02/05/2026
Dalet, a leading technology and service provider for media-rich organizations, t...
01/05/2026
January 5 2026, 18:30 (PST) NBCUniversal's Peacock to Be First Streamer to ...
01/04/2026
January 4 2026, 18:00 (PST) DOLBY AND DOUYIN EMPOWER THE NEXT GENERATON OF CREATORS WITH DOLBY VISION
Douyin Users Can Now Create And Share Videos With Stun...
21/02/2026
With Software Defined Broadcasting more established in Milan Cortina look for Los Angeles 2028 to have less hardware and more cloud-based software systems...
21/02/2026
The SVP of Olympic Operations on turning CAD drawings into reality, building tru...
21/02/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
21/02/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
21/02/2026
Back to All News
Netflix Unveils the Trailer of Accused', A Psychological ...
20/02/2026
Gravity Media and Los Angeles-based Green Couch Entertainment announce a strateg...
20/02/2026
IMAX announces it is working with Apple TV to bring the 2026 FIA Formula One Wor...
20/02/2026
Daktronics has partnered with the Philadelphia Phillies to design, manufacture, ...
20/02/2026
ESPN announces the upcoming launch of Women's Sports Sundays - a first-of-it...
20/02/2026
As the Seattle Seahawks and New England Patriots faced off in the NFL's biggest sporting event of the season on Sun., Feb. 8, Sennheiser wireless solutions ...
20/02/2026
ESPN announces its 2026 Major League Baseball spring training schedule, which includes four national games on ESPN, six games on ESPN Unlimited, and more than 2...
20/02/2026
Open Broadcast Systems, which specializes in software-based professional video transport, has added support for 200 Gigabit Ethernet to its range of encoders an...
20/02/2026
Chyron announces the release of PAINT 10.3, which is designed to help analysts and operators turn live action into clearer, faster on-air storytelling.
PAINT 1...
20/02/2026
With full squad workouts underway, MLB Network's live Spring Training game s...
20/02/2026
Tech enhancements, marquee productions are expected to take advantage of a summe...
20/02/2026
In-venue and creative video staffers at the professional and collegiate level ha...
20/02/2026
Ratings Roundup is a rundown of recent rating news and is derived from press rel...
20/02/2026
Speaking with SVG Europe after one of Team GB's greatest days at a Winter Olympics, BBC Sport's head of major events, Ron Chakraborty, explains the broa...
20/02/2026
Making Winter Games Olympic magic is the goal for every broadcaster in Italy cov...
20/02/2026
Curling, one of the least-dangerous Winter Olympic sports, is dominating the Mil...
20/02/2026
BBC Sport's presence at the 2026 Winter Games is centred around a significan...
20/02/2026
BBC Sport is bringing together its linear TV and streaming digital arms in a str...
20/02/2026
To broaden the appeal of winter sports at Milano Cortina, the BBC has integrated...
20/02/2026
Just in time for the start of Apple TV's inaugural season as the exclusive U...
20/02/2026
One big challenge was to depict the character of each of very different and wide...
20/02/2026
(L-R) Writer-director Amanda Kramer photographs the photographers at the premiere of her film By Design at the Library Center Theatre in Park City. (Photo by ...
20/02/2026
In our latest blog, Tim Pearson explores the impact that increased memory prices are having on the consumer electronics market, and particularly the set-top box...
20/02/2026
Calrec Type R: Shaping the Future of Radio from the Heart of Flirt FM
Love may have filled the airwaves last week for Valentine's Day, and we've just c...
20/02/2026
NEW YORK - February 10, 2026 - An estimated 125.6* million viewers watched Super Bowl LX on Sunday, February 8, according to Nielsen's Big Data Panel meas...
20/02/2026
NEW YORK - February 19, 2026 - Nielsen today shared updated and final Super Bowl...
20/02/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/02/2026
A leading global investment bank, with offices at Two International Finance Centre in Hong Kong, partnered with systems integrators Global Vision Engineering (G...
20/02/2026
Rise AV and Rise Broadcast, the global not-for-profit organisations dedicated to improving gender diversity across technical industries, have today announced a ...
20/02/2026
Open Broadcast Systems, the leader in software-based professional video transport, has added support for 200 Gigabit Ethernet to its range of encoders and decod...
20/02/2026
Signiant today announced the formation of its Customer Advisory Board (CAB), bringing together a select group of customers to collaborate on product strategy, r...
20/02/2026
PTZOptics today announced the launch of its Visual Reasoning initiative that makes video more actionable by combining robotic PTZ camera systems, AI, and open i...
20/02/2026
Amino, a global media technology provider delivering devices, software and cloud services that simplify and elevate video delivery, today announced the successf...
20/02/2026
SMPTE , the home of media professionals, technologists, and engineers, today announced its call for technical papers for the SMPTE 2026 Media Technology Summit....
20/02/2026
Wowza Media Systems today announced that Granicus, a leading provider of digital engagement solutions for governments, continues to rely on Wowza to power its h...
20/02/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/02/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/02/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/02/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/02/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/02/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...