
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...
04/07/2025
By Lucy Spicer
Editor's note: We are deeply saddened by the passing of Robe...
04/07/2025
The Summer Reading Challenge has inspired children across the U.K. to embrace a ...
04/07/2025
Introducing CVP Auctions: Trusted Tech, At Auction-Only Prices
Brie Clayton July 4, 2025
0 Comments
A New Destination for Film and Broadcast Gear at U...
04/07/2025
Unveiling China's Ecological Wonders with URSA Mini Pro 12K
Brie Clayton July 4, 2025
0 Comments
Nature Documentaries Freeze Epic Momentsin Extrem...
04/07/2025
Create Any Planet in After Effects
Graham Quince July 4, 2025
0 Comments
The Advanced 3D renderer in After Effects makes it really easy to import 3D o...
04/07/2025
Custom Gradient Colorize for Resolve Fusion
Simon Ubsdell July 4, 2025
0 Comments
Digging into the theory of the gradient colorize process to build ou...
04/07/2025
Watching live sports on TV these days is a delicate balance for broadcasters how much information is too much?...
04/07/2025
WASHINGTON As Federal Communications Commission Chair Brendan Carr works to achieve his goal of a very busy, productive summer at the FCC, the agency has rele...
04/07/2025
Other World Computing Launches OWC Guardian USB-C Hardware-Encrypted Portable SS...
04/07/2025
CANAL Brings MotoGP to Vision Pro with Blackmagic URSA Cine Immersive
Brie Clayton July 3, 2025
0 Comments
Experience MotoGP like never before as CA...
04/07/2025
Friday 4 July 2025
Watch the trailer here https://youtu.be/Od5WpvWmDr8
Further...
04/07/2025
The Pitch comes to RT Radio 1 airwaves this Sunday at 7pm. The Pitch is a brand...
03/07/2025
For our Vario-Jib, as well as for a repertoire of weights, we now have carts that make transport easier...
03/07/2025
One of our latest innovations: Slider Drive Unit!
Our Vario Slider not only comes with improvements and new features, but also with its own drive unit!
Our i...
03/07/2025
The 360 EVO lives up to its name: 360-degree rotation not only on the pan axis, but also on the roll axis, enables filmmakers to take their creative visions eve...
03/07/2025
What a buzzing few days at BSCExpo in London!
We were thrilled to connect with so many talented professionals from the world of cinematography.
A huge thank ...
03/07/2025
ADOLESCENCE - Shot with Panther Tower"The whole rig had to be detachable mid-episode
Netflix limited drama series Adolescence has been gaining attentio...
03/07/2025
To achieve a true level of decisive overmatch, communication systems must be as ...
03/07/2025
The Broadcasters Foundation of America has named Ray Hopkins, president of U.S. distribution at Paramount Global, to its board of directors....
03/07/2025
SIOUX FALLS, S.D. In his first major policy speech, Federal Communications Commission chair Brendan Carr outlined his Build America Agenda for the agency'...
03/07/2025
As the industry is making a major push to transition to NextGen TV and develop new businesses that will fund the next generation of broadcasting, TV Tech's ...
03/07/2025
Despite enabling its subscribers to watch films and TV shows in the highest possible resolution, Netflix has revealed it is taking things old school with the in...
03/07/2025
WASHINGTON In response to news that Paramount Global has agreed to pay $16 million to settle a lawsuit by President Donald Trump, Democrats and other administra...
03/07/2025
WUPPERTAL, Germany Riedel Communications today launched RefSuite for professional sports workflows....
03/07/2025
WEITERSTADT, Germany LYNX Technik, a provider of modular signal processing solutions, has announced that founder and longtime CEO Winfried Deckelmann is steppin...
03/07/2025
WASHINGTON Representatives from six trade groups representing tech, pay TV, broadband, LPTV and other sectors recently met with Federal Communications Commissio...
03/07/2025
PLYMOUTH, Wis. Dan Whealy has acquired Heartland Video Systems and will be its new owner and president, the systems integrator said....
03/07/2025
Acclaimed filmmaker, educator, and industry veteran Jay Holben has released his most ambitious work to date: The Director's Guide to Everything a sweeping...
03/07/2025
For Los Angeles-based photographer Scout Pruski, documenting the annual Dyke Day LA is a way to honor and give back to the city's legacy queer community and...
03/07/2025
Modular, Travel-Ready Solution Matthews Studio Equipment launches the new Chimera V-Flat Panel Frame Kit, the lightweight and modular, ultra-durable alternativ...
03/07/2025
Dalet, a leading technology and service provider for media-rich organizations, today announced the release of Dalet Flex 2025.6 LTS (long-term support), introdu...
03/07/2025
Lightware's LARA Wizard makes it quicker and easier than ever to set up audio-visual (AV) room automation and control configurations, ensuring anyone, from ...
03/07/2025
Alfalite, the only European manufacturer of LED screens, has obtained both the NCAGE Code (NATO Commercial and Government Entity) and TAA (Trade Agreements Act)...
03/07/2025
nxtedition is implementing a new solution for WIN Network, based in its headquarters in Wollongong, New South Wales, Australia. The nxtedition integrated platfo...
03/07/2025
ORS Group and Insys Video Technologies today announce the launch of a new joint brand identity: Big Blue Marble. The move reflects the evolution of a long-stand...
03/07/2025
Evergent, a global leader in customer lifecycle management and monetization solutions for subscription-based businesses, today announced the successful results ...
03/07/2025
LYNX Technik, provider of modular signal processing solutions today announces an executive leadership transition, effective July 1, 2025. Markus Motzko has been...
03/07/2025
Chaos Releases V-Ray for Blender
Brie Clayton July 2, 2025
0 Comments
Production-Proven Renderer V-Ray Arrives Natively in Blender for the First Time;...
03/07/2025
Calvin University Adds Blackmagic Replay to Broadcasts and Streams
Brie Clayton July 2, 2025
0 Comments
Replay workflow joins 14 Blackmagic Design cam...
03/07/2025
Berklee's Gospel Performance Program Welcomes Jonathan Nelson as the Herb Al...
03/07/2025
Back to All News
Get Ready for Even More Action! Netflix Has Confirmed the Thir...
03/07/2025
Back to All News
Get ready for even more action! Netflix has confirmed the thir...
03/07/2025
In today's fragmented media landscape, advertisers expect more than just reach - they want seamless cross-platform campaigns that deliver measurable results...
03/07/2025
** MEDIA ALERT ** Shonen Jump Store Hosting Los Angeles Pop-up During Anime Exp...
03/07/2025
Thursday 3 July 2025
David Harewood and Matthew Broome in Mozart: Genius for Hi...
03/07/2025
The Sky WNT Fund supports Womens National Team players with a 30,000 bursaryThursday 3 July 2025
Sky Ireland has announced the four recipients of the 2025 Sky...
03/07/2025
The forecast this month is showing a 100% chance of epic gaming. Catch the scorching lineup of 20 titles coming to the cloud, which gamers can play whether indo...
02/07/2025
Hege Wik and Odin appear in FOLKTALES by Heidi Ewing and Rachel Grady, an official selection of the 2025 Sundance Film Festival. Courtesy of Sundance Institut...