
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
06/10/2025
France T l visions, France's leading broadcaster, has received the 2025 EBU ...
04/09/2025
Monumental Sports & Entertainment (MSE), in collaboration with Dalet, has been a...
07/08/2025
July 8 2025, 22:30 (PDT) Tata Motors & Dolby Bring Dolby Atmos to Harrier.ev, R...
29/07/2025
Staines-upon-Thames, UK, 29 July, 2025 Yospace, the global leader in Dynamic Ad ...
29/07/2025
Six Fellows Selected for Program Supporting Projects From Transgender Storytellers of Color
Today the nonprofit Sundance Institute announced the six artists p...
29/07/2025
By Jessica Herndon
One of the most exciting things about the Sundance Film Fest...
29/07/2025
Today, we announced our second quarter 2025 earnings, fueled by standout subscriber and MAU growth. In the first half of 2025, subscriber net additions grew mor...
29/07/2025
Idag rapporterar vi resultatet f r andra kvartalet 2025, med stark tillv xt av antalet prenumeranter och m natliga aktiva anv ndare. Under f rsta halv ret kade...
29/07/2025
Streaming Holds Steady in a Lighter Summer Viewership Season
NEW YORK - July 29...
29/07/2025
NEW YORK Nielsen is reporting that viewing of content with ads became more popular in Q2, 2025, gaining 1.2 share points of overall TV viewing to capture 73.6% ...
29/07/2025
SAN ANTONIO QuickLink has launched two new versions of its StudioEdge line of products: StudioEdge-1 and StudioEdge-2 provide one-channel and two-channels of br...
29/07/2025
The Society of Broadcast Engineers has announced the recipients of the 2025 SBE National Awards, which recognize outstanding achievements by individual members,...
29/07/2025
CHAMPAIGN, Ill. Cobalt Digital is heading to IBC 2025 with an expanded lineup of IPMX-compliant products and solutions that highlight its simple plug-and-play a...
29/07/2025
AMSTERDAM German manufacturer Guntermann & Drunck GmbH (G&D) has announced that it will present a wide range of KVM and video processing solutions for broadcast...
29/07/2025
At IBC 2025 in Amsterdam (September 12 15), German manufacturer Guntermann & Drunck GmbH (G&D) will present a range of intelligent solutions designed to meet th...
29/07/2025
MoU will support the Map Africa Initiative, a program designed to create a con...
29/07/2025
X-Rite Launches CT2100 Spectrophotometer for Fast, Affordable Retail Paint Color...
29/07/2025
Filming is now underway with Damien Molony and wider cast returning to Jersey for Bergerac, written by Toby Whithouse alongside Ashley Sanders, Emilie Robson an...
29/07/2025
NBA Summer League Tests Out, Refines Audio Workflows New mic arrays and ways of mixing them are a focus By Dan Daley, Audio Editor
Tuesday, July 29, 2025 - 7...
29/07/2025
Athlete Audio Builds Fan Engagement, Player Branding at WNBA All-Star Specialist A2 Ron Thompson has helped the technology evolve for decades By Dan Daley, Aud...
29/07/2025
Dante, Dell Technologies, Google, SMT, and Wave Central Renew Corporate Sponsors...
29/07/2025
Ross Video Case Study: How to Draw Fans Deeper into the Game By SVG Staff
Tuesday, July 29, 2025 - 11:36 am
Print This Story | Subscribe
Story Highlight...
29/07/2025
FIFA Club World Cup 2025: Sounding off with HBS at the largest production for a ...
29/07/2025
Back to All News
Breathless Returns to Netflix, Premiering October 31stPlay Video
Play Video
Entertainment
29 July 2025
GlobalSpain
Link copied to clipboa...
29/07/2025
Back to All News
Made in New Jersey: Finding the Perfect Shot for Our Hit Seque...
29/07/2025
Relationship Marks First U.S.-Based Distribution Partnership for FOR-A America...
29/07/2025
A wide shot of MID's new Public Meeting Chambers in session, showcasing the ...
29/07/2025
Through reliable connectivity and industry-leading levels of data completeness, Arqiva is helping water companies to meet regulatory targets and push for a wate...
28/07/2025
Summer is here, and whether you're road-tripping, relaxing poolside, or hosting friends for a backyard barbecue, the right soundtrack can make every moment ...
28/07/2025
In 2021, Spotify launched Amplifika in Brazil as a dedicated program to foster t...
28/07/2025
Summer is the perfect time to dive into a new story, whether you're on the move or just looking for an escape. With Spotify Premium, eligible listeners in s...
28/07/2025
IABM, the International Trade Association for Broadcast and Media Technology, has confirmed the appointment of its Members' Board for 2025, following the co...
28/07/2025
Media Prima has chosen DHD SX2 audio production mixers for integration into new broadcast studios at Balai Berita in Bangsar on the southwest periphery of Kuala...
28/07/2025
MNC Software, a global leader in network management and operational support systems tailored to the broadcast and media industry, has won a major monitoring and...
28/07/2025
Back to All News
Netflix Unveils the Official Trailer for the Limited Series Tw...
28/07/2025
Back to All News
New Korean Romantic Comedy Take Charge of My Heart' Produ...
28/07/2025
Kerry's dominant All Ireland Football Final display draws a peak of over one...
28/07/2025
Kerry's dominant All Ireland Football Final display draws a peak of over one...
28/07/2025
The electrical grid is designed to support loads that are relatively steady, such as lighting, household appliances, and industrial machines that operate at con...
28/07/2025
28 Jul 2025
VEON's Beeline Kazakhstan Opens New Office in Almaty Supporting...
28/07/2025
New classic: EMG / Gravity Media France on overlapping schedules and athlete acc...
28/07/2025
Indiana Pacers Sports & Entertainment's Emily Wright on the IP-based Tech Tr...
28/07/2025
Live From National Baseball Hall of Fame Induction: Cooperstown Is at the Heart ...
28/07/2025
SVG Attendees Get Shared Reality' Treatment at Cosm Experience & Tech Tour ...
28/07/2025
Monday 28 July 2025
To view this content, please enable our use of cookies. To ...
28/07/2025
Monday 28 July 2025
To view this content, please enable our use of cookies. To ...
28/07/2025
LinkedIn Wins Legal Battle to Protect Member Data Published on Jul 28, 2025 Categories: Company News
LinkedIn Corporate Communications
Share
LinkedIn ...
26/07/2025
IABM, the International Trade Association for Broadcast and Media Technology, has confirmed the appointment of its Members' Board for 2025, following the co...
26/07/2025
BALTIMORE In another sign that dealmaking for U.S. TV stations may be heating up amid hopes that regulators will eliminate or loosen broadcast ownership caps, S...
26/07/2025
LISBON wTVision, a provider of real-time graphics and broadcast services, has established a strategic alliance with Adistec that will see Adistec will distribut...