• Our new ticketing site is now live! Using either this or the original site (both powered by TrainSplit) helps support the running of the forum with every ticket purchase! Find out more and ask any questions/give us feedback in this thread!

ATOC Fares Download

Status
Not open for further replies.

johnnycache

Member
Joined
3 Jan 2012
Messages
421
I've registered. I've got my 25 file download. I've got my fares flow file and I can proudly tell you that the flow reference for Brighton (5268) to London Terminals (1072) Route Any Permitted (0000) is 0181507 which enables me to access all the adult undiscounted prices (in pence) for each ticket type. But can anyone tell me what I can do now so I can begin to manipulate the data?
 
Sponsor Post - registered members do not see these adverts; click here to register, or click here to log in
R

RailUK Forums

soil

Established Member
Joined
28 May 2012
Messages
2,311
A good few hours writing code.

I haven't finished importing it (only imported locations (stations), fares and flows - no ticket types for example), but having imported into a database, I am able to run queries like this one:

select isnull(origin.Description, originlocation.description),
isnull(destination.description, destlocation.description), FlowFares.fare from
flows
join flowfares on FlowFares.FlowId = flows.flowid
left join Locations Destination on Destination.NLCCode = Flows.DestinationCode
left join Clusters DestCluster on DestCluster.ClusterID = flows.DestinationCode
left join Locations DestLocation on DestLocation.NLCCode = DestCluster.ClusterNLC
left join Locations Origin on Origin.NLCCode = Flows.OriginCode
left join Clusters OriginCluster on OriginCluster.ClusterID = flows.OriginCode
left join Locations OriginLocation on OriginLocation.NLCCode = OriginCluster.ClusterNLC
where FlowFares.RestrictionCode = 'L7' and FlowFares.TicketCode != 'C2R'

This finds fares with restriction code L7, excluding C2R (group) tickets. The list is:

BROMSGROVE EVESHAM 350
BROMSGROVE HONEYBOURNE 350
BROMSGROVE PERSHORE. 350
BROMSGROVE MORETON IN MARSH 350
COLWALL MALVERN LINK 350
COLWALL PERSHORE. 350
DROITWICH SPA MORETON IN MARSH 350
DROITWICH SPA PERSHORE. 350
DROITWICH SPA HONEYBOURNE 350
DROITWICH SPA EVESHAM 350
EVESHAM BROMSGROVE 350
EVESHAM HEREFORD 350
EVESHAM WORCESTER STNS 350
EVESHAM DROITWICH SPA 350
EVESHAM LEDBURY 350
EVESHAM MORETON IN MARSH 350
EVESHAM COLWALL 350
EVESHAM MALVERN LINK 350
EVESHAM GREAT MALVERN 350
HEREFORD MORETON IN MARSH 350
HONEYBOURNE BROMSGROVE 350
HONEYBOURNE WORCESTER STNS 350
HONEYBOURNE MORETON IN MARSH 350
HONEYBOURNE COLWALL 350
HONEYBOURNE MALVERN LINK 350
HONEYBOURNE PERSHORE. 350
HONEYBOURNE GREAT MALVERN 350
HONEYBOURNE DROITWICH SPA 350
HONEYBOURNE WORCESTER STNS 350
HONEYBOURNE HEREFORD 350
LEDBURY HONEYBOURNE 350
LEDBURY MORETON IN MARSH 350
LEDBURY COLWALL 350
LEDBURY MALVERN LINK 350
LEDBURY PERSHORE. 350
LEDBURY GREAT MALVERN 350
MALVERN LINK PERSHORE. 350
MORETON IN MARSH WORCESTER STNS 350
MORETON IN MARSH BROMSGROVE 350
MORETON IN MARSH DROITWICH SPA 350
MORETON IN MARSH EVESHAM 350
MORETON IN MARSH HONEYBOURNE 350
MORETON IN MARSH COLWALL 350
MORETON IN MARSH MALVERN LINK 350
MORETON IN MARSH PERSHORE. 350
MORETON IN MARSH GREAT MALVERN 350
PERSHORE. WORCESTER STNS 350
PERSHORE. HONEYBOURNE 350
PERSHORE. MORETON IN MARSH 350
PERSHORE. GREAT MALVERN 350
PERSHORE. HEREFORD 350
PERSHORE. WORCESTER STNS 350
PERSHORE. DROITWICH SPA 350
PERSHORE. BROMSGROVE 350
WORCESTER STNS HONEYBOURNE 350
WORCESTER STNS PERSHORE. 350
WORCESTER STNS MORETON IN MARSH 350
WORCESTER STNS EVESHAM 350
WORCESTER STNS HONEYBOURNE 350
WORCESTER STNS PERSHORE. 350

As you can see, tickets are available for stations between Hereford and Moreton-in-Marsh.

Here's the database schema I'm using

http://pastebin.com/fr3Au3LV (note it's just my personal work-in-progress schema, and is incomplete, has erroneous, poorly design and so on)

This is using Microsoft SQL Server

I then imported the data using a C# program. I used the Entity Framework add in Microsoft Visual Studio .NET to rapidly generate objects

http://msdn.microsoft.com/en-gb/data/ef.aspx

It's relatively straightforward then to import the data. I used SQL Bulk Copy to expedite the import process (100x speed improvement)

Here's the script that I've not bothered to finish, but got me that far:

http://pastebin.com/Mg0LzAha


You can download a free version of SQL Server that is more than adequate for this

http://www.microsoft.com/en-us/sqlserver/editions/2012-editions/express.aspx

It is not at all necessary to use C# to do the import. In fact you can use SQL server alone, with the BULK INSERT command, to import from the data files. I used C# because I have it installed and have the relevant rapid prototyping tools.

If you do not have programming experience, I would stick with SQL only, since this is the key to getting useful data out of the database.

I would start by installing SQL Server Express, create the database and tables (you can use the GUI or my scripts above), and then run BULK INSERT to get the data into the columns.

As I recall, the flows file contains two types of data, Flows and Flow Fares. I would split this into two separate files. The locations file contains around 5 different record types. I wrote a description here:
http://railforums.co.uk/showpost.php?p=1394720&postcount=28

In order to get useful data as a starting point, I would save the 'L' records only as a separate file, and then run a BULK INSERT into the Locations table.
 

34D

Established Member
Joined
9 Feb 2011
Messages
6,044
Location
Yorkshire
It's relatively straightforward then to import the data.

Not for those of us who are now totally confused it isn't!! But fair play to you for the programs you have produced. Well done sir.
 

kieron

Established Member
Joined
22 Mar 2012
Messages
3,283
Location
Connah's Quay
Not for those of us who are now totally confused it isn't!! But fair play to you for the programs you have produced. Well done sir.
No, but it does mean that if you wanted to know (say) which routes have flexible tickets routed via Birmingham which cost less than £20, you know there's someone around here who could find out in a minute or two.
 
Status
Not open for further replies.

Top