Packages for processing TransXchange and Netex files

Hello! I’m very new to PT data so these question may be a bit obvious.

I’m interested in using the Fares and Timetables data from the bus open data service but I’m finding the transXchange and Netex formats very dense. Are there any packages people would recommend for processing them directly (preferably written in python).

Cheers!

Hello and welcome to the forum!

I can’t say I’ve used any of them, but there are packages listed on PyPI for TransXChange and NeTEx.

It’s not a distinct package, but bustimes.org’s TransXChange processor is written in Python and available under the Mozilla Public License.

I’m curious to hear if anyone else has experience with packages for these formats!

1 Like

I wrote all my TransXchange code in PHP Classes. Just 407 lines and a 143 lines of helper class. It’s acutally quite simple as PHP can turn XML to objects with just…

            libxml_use_internal_errors(true);
            $dom = new DOMDocument();
            $dom->preserveWhiteSpace = false;
            $dom->loadXML((string)$this->cachedGetTransxchangeitemByFilename($pk));
            $this->TransXChange = $dom->getElementsByTagName('TransXChange');
1 Like

It may depend on what the subsequent use is and on how industrial a scale. Most of my subsequent usage is in Excel, so it was fairly natural (and worth the investment) to read the XML, understand the standardised data structure and write VBA code to read in several hundred XML files and extract what I wanted into formats that made sense for the next stage. Which is fine for me … unless some bright spark rips up the structure.

For what it is worth, I think I did try bustimes.org’s TransXChange processor but found it slow, so I stuck with what I already had.

1 Like

I would always recommend using a language which will allow you to create a set of classes from an XML Schema Definition (XSD). Not only should you be able to read the documentation embedded in the XSD, but it makes parsing a breeze.

But then again, my background is very enteprise-y, working with systems that need to be extremely robust.

1 Like