Time Table project

Goal of this project is to provide free (GPL-ed) tools for searching bus/train time tables.

Timetable project

Goal of this project is to create system for searching in bus/train timetables. You should be able to say timetab 'Praha hl.n.' 1.5.2000 10:00 'Brno hl.n.' and get best possible connection from Prague main station to Brno main station. [Currently, it gives you connection, which arrivest the soonest to each town -- not exactly the best one; better searcher called travel is already in CVS.]

For this purpose you need database of all relevant trains. Getting the database is not exactly trivial: of course you could copy it from paper timeables by hand, but databasse would likely be obsolete at time you finished copying (my estimate is that manual copying of CDrail database would take 550 hours).


Timetab is program which searches best connection. It takes database in .tt format on input, and creates auxiliary (name).mem image for speeding up further searches. (Be sure to delete (name).mem each time you change timetab.c.)

.tt database is in ASCII format. Format of .tt database should be rather easy to see: It is in records separated by # name of connection line. Each record contains lines with items separated by tabelator (time of arrival, time of departure, remark, kilometers, name of town). Trivial compression is applied: when previous time was 10:00, +5 means 10:05. (This allows bzip to compress generated file 2 times better.) Similar compression is applied to kilometers.


Travel is using different format of database (using .t extension). To generate this file, use script similar to this.

../timetab -tv > vlak.t
../timetab -ti >> vlak.t
#../timetab -xp > vlak.2
wc -l vlak.2 >> vlak.t
cat vlak.2 >> vlak.t
rm vlak.2

Travel uses very sophiscated algorithm based on badness of connection -- it does not search 'fastest' connection (like timetab always does), but 'best' connection, based on P_XXX macros in sources.

Tools for getting database

I have some tools for downloading databases from the web, but you probably do not want to do that yourself. 500MB of data are transfered over the web when downloading CDrail database, and it takes few hours to process database into .tt format. Tools for getting databases are in directory corresponding to top level domain of the country. Currently only cz/ is supported.

Once you have both railways and buses, you may want to search in both of them at the same time. No problem. With samegen, you can generate same.tt (database of "walks" between stations). Combining databases is then as easy as cat same.tt bus.tt vlak.tt > xyzzy.tt.


You certainly need timetab.c (compile it with gcc -O2 timetab.c -o timetab). Then you need some database files. These are .tt files, bzip2 compressed. Uncompress them with bzip2 -d file.tt.bz2 before use. 2000/20001 databases of czech railways vlak.tt.bz2 and Czech autobuses bus.tt.bz2 and Prague transportation system pid.tt.bz2 are available. Combined database of autobuses and trains is also available xyzzy.tt.bz2

Pavel Machek