CSV Data


In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

In [12]:
path_to_csv = '../NapTAN/NaPTANcsv/RailReferences.csv'
df = pd.read_csv(path_to_csv)
df


Out[12]:
AtcoCode TiplocCode CrsCode StationName StationNameLang GridType Easting Northing CreationDateTime ModificationDateTime RevisionNumber Modification
0 9100ABDARE ABDARE ABA Aberdare Rail Station NaN U 300400 202800 2003-11-04T00:00:00 2006-09-18T18:24:34 2 rev
1 9100ABDO ABDO AUR Aberdour Rail Station NaN U 319100 685400 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2 9100ABDVY ABDVY AVY Aberdovey Rail Station NaN U 260600 296000 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
3 9100ABER ABER ABE Aber Rail Station NaN U 314870 186950 2005-03-18T00:00:00 2006-09-18T18:24:34 1 rev
4 9100ABGLELE ABGLELE AGL Abergele & Pensarn Rail Station NaN U 294612 378681 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
5 9100ABRCYNS ABRCYNS ACY Abercynon Rail Station NaN U 308278 194824 2003-11-04T00:00:00 2008-06-05T17:01:49 2 rev
6 9100ABRDEEN ABRDEEN ABD Aberdeen Rail Station NaN U 394127 805872 2003-11-04T00:00:00 2009-04-15T15:26:29 2 rev
7 9100ABRE ABRE ABH Abererch Rail Station NaN U 240400 336100 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
8 9100ABRGVNY ABRGVNY AGV Abergavenny Rail Station NaN U 330500 213600 2003-11-04T00:00:00 2006-09-18T18:24:34 2 rev
9 9100ABRYSTH ABRYSTH AYW Aberystwyth Rail Station NaN U 258500 281600 2003-11-04T00:00:00 2007-02-13T17:06:21 4 rev
10 9100ABWD ABWD ABW Abbey Wood (London) Rail Station NaN U 547374 179035 2003-11-04T00:00:00 2010-05-14T17:36:24 2 rev
11 9100ACBG ACBG ACB Acton Bridge Rail Station NaN U 359870 374560 2003-11-04T00:00:00 2011-03-24T17:35:58 2 rev
12 9100ACHANLT ACHANLT AAT Achanalt Rail Station NaN U 226020 861473 2003-11-04T00:00:00 2010-02-25T14:53:53 2 rev
13 9100ACHHSHL ACHHSHL ACH Achnashellach Rail Station NaN U 200290 848440 2005-03-18T00:00:00 2006-09-18T18:24:34 1 rev
14 9100ACHILCK ACHILCK AUK Auchinleck Rail Station NaN U 255000 622000 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
15 9100ACHNSHN ACHNSHN ACN Achnasheen Rail Station NaN U 216403 858519 2003-11-04T00:00:00 2010-02-25T14:54:15 2 rev
16 9100ACKLNGT ACKLNGT ACK Acklington Rail Station NaN U 422200 601500 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
17 9100ACLE ACLE ACL Acle Rail Station NaN U 639900 310000 2003-11-04T00:00:00 2006-09-18T18:24:34 2 rev
18 9100ACOCKSG ACOCKSG ACG Acocks Green Rail Station NaN U 412400 283500 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
19 9100ACRNGTN ACRNGTN ACR Accrington Rail Station NaN U 375730 428575 2003-11-04T00:00:00 2011-02-07T18:49:18 7 rev
20 9100ACTNCTL ACTNCTL ACC Acton Central Rail Station NaN U 520645 180295 2003-11-04T00:00:00 2010-05-14T17:36:24 2 rev
21 9100ACTONML ACTONML AML Acton Main Line Rail Station NaN U 520360 181230 2003-11-04T00:00:00 2010-05-14T17:36:24 2 rev
22 9100ADERLYP ADERLYP ADD Adderley Park Rail Station NaN U 409880 287250 2005-03-18T00:00:00 2006-09-18T18:24:34 1 rev
23 9100ADIEWEL ADIEWEL ADW Addiewell Rail Station NaN U 299500 662300 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
24 9100ADISHAM ADISHAM ADM Adisham Rail Station NaN U 623391 153976 2005-04-21T00:00:00 2006-09-18T18:24:34 1 rev
25 9100ADLC ADLC ADC Adlington (Cheshire) Rail Station NaN U 391200 380300 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
26 9100ADLESTN ADLESTN ASN Addlestone Rail Station NaN U 505587 164866 2005-04-21T00:00:00 2006-09-18T18:24:34 1 rev
27 9100ADNL ADNL ADL Adlington (Lancs) Rail Station NaN U 360200 413135 2003-11-04T00:00:00 2011-02-07T18:49:18 2 rev
28 9100ADWICK ADWICK AWK Adwick Rail Station NaN U 454375 408725 2003-11-04T00:00:00 2010-12-20T15:37:54 2 rev
29 9100AGHTNPH AGHTNPH AUG Aughton Park Rail Station NaN U 340790 406775 2003-11-04T00:00:00 2011-02-07T18:49:18 2 rev
... ... ... ... ... ... ... ... ... ... ... ... ...
2573 9100WTCR WTCR WCR Whitecraigs Rail Station NaN U 255250 657640 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2574 9100WTLESFD WTLESFD WLF Whittlesford Parkway Rail Station NaN U 548420 247240 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2575 9100WTRNGBY WTRNGBY WTR Wateringbury Rail Station NaN U 569160 152850 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2576 9100WTRORTN WTRORTN WTO Water Orton Rail Station NaN U 417530 291220 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2577 9100WVLSFLD WVLSFLD WVF Wivelsfield Rail Station NaN U 532060 120000 2005-04-21T00:00:00 2011-08-22T17:03:04 2 rev
2578 9100WVRMPTN WVRMPTN WVH Wolverhampton Rail Station NaN U 392000 298900 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2579 9100WVRTTEC WVRTTEC WAV Wavertree Technology Park Rail Station NaN U 338741 390216 2003-11-04T00:00:00 2008-11-17T19:06:08 2 rev
2580 9100WWICKHM WWICKHM WWI West Wickham Rail Station NaN U 538276 166565 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2581 9100WWRTHNG WWRTHNG WWO West Worthing Rail Station NaN U 513300 103320 2005-04-21T00:00:00 2007-02-13T17:06:21 3 rev
2582 9100WYEE WYEE WYE Wye Rail Station NaN U 604813 146943 2005-04-21T00:00:00 2006-09-18T18:24:34 1 rev
2583 9100WYGN WYGN WYL Wylde Green Rail Station NaN U 411530 294220 2003-11-04T00:00:00 2010-04-01T16:15:28 2 rev
2584 9100WYLAM WYLAM WYM Wylam Rail Station NaN U 412000 564500 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2585 9100WYMNDHM WYMNDHM WMD Wymondham Rail Station NaN U 611423 300965 2003-11-04T00:00:00 2008-12-01T15:27:09 4 rev
2586 9100WYTH WYTH WYT Wythall Rail Station NaN U 409250 275775 2003-11-04T00:00:00 2011-11-03T16:09:31 2 rev
2587 9100YAAM YAAM YRM Yarm Rail Station NaN U 442100 511145 2003-11-04T00:00:00 2009-10-16T14:38:56 2 rev
2588 9100YALDING YALDING YAL Yalding Rail Station NaN U 568526 150241 2005-04-21T00:00:00 2006-09-18T18:24:34 1 rev
2589 9100YARMTH YARMTH GYM Great Yarmouth Rail Station NaN U 652000 308100 2003-11-04T00:00:00 2007-02-13T17:06:21 4 rev
2590 9100YATE YATE YAE Yate Rail Station NaN U 370100 182500 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2591 9100YATTON YATTON YAT Yatton Rail Station NaN U 342500 166100 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2592 9100YEOFORD YEOFORD YEO Yeoford Rail Station NaN U 278325 98905 2003-11-04T00:00:00 2010-10-06T16:42:54 2 rev
2593 9100YNYSWEN YNYSWEN YNW Ynyswen Rail Station NaN U 294860 197340 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2594 9100YOKER YOKER YOK Yoker Rail Station NaN U 250870 669180 2003-11-04T00:00:00 2011-08-22T17:03:04 2 rev
2595 9100YORK YORK YRK York Rail Station NaN U 459600 451700 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2596 9100YORTON YORTON YRT Yorton Rail Station NaN U 350454 323744 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2597 9100YOVILJN YOVILJN YVJ Yeovil Junction Rail Station NaN U 357050 114100 2003-11-04T00:00:00 2010-07-26T14:39:00 2 rev
2598 9100YOVILPM YOVILPM YVP Yeovil Pen Mill Rail Station NaN U 357000 116300 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2599 9100YRDLYWD YRDLYWD YRD Yardley Wood Rail Station NaN U 410000 280400 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2600 9100YSTRADM YSTRADM YSM Ystrad Mynach Rail Station NaN U 314200 194300 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev
2601 9100YTMNSTR YTMNSTR YET Yetminster Rail Station NaN U 359745 110855 2003-11-04T00:00:00 2010-04-01T16:15:28 2 rev
2602 9100YTRHOND YTRHOND YSR Ystrad Rhondda Rail Station NaN U 298610 194890 2003-11-04T00:00:00 2006-09-18T18:24:34 1 rev

2603 rows × 12 columns


In [38]:
df[df['StationName'] == 'London Waterloo Rail Station'].index.tolist()


Out[38]:
[2405]

In [39]:
df.iloc[2405]


Out[39]:
AtcoCode                                 9100WATRLMN
TiplocCode                                   WATRLMN
CrsCode                                          WAT
StationName             London Waterloo Rail Station
StationNameLang                                  NaN
GridType                                           U
Easting                                       531060
Northing                                      179950
CreationDateTime                 2003-11-04T00:00:00
ModificationDateTime             2009-10-13T16:26:29
RevisionNumber                                     2
Modification                                     rev
Name: 2405, dtype: object

XML Data


In [6]:
import xml.etree.cElementTree as ET

In [7]:
path_to_xml = '../NapTAN/NaPTAN.xml'
tree = ET.ElementTree(file=path_to_xml)

In [4]:
#from lxml import etree
#root = etree.Element("root")

In [14]:
root = tree.getroot()

In [15]:
for child_of_root in root:
  print child_of_root.tag, child_of_root.attrib


{http://www.naptan.org.uk/}StopPoints {}
{http://www.naptan.org.uk/}StopAreas {}

In [16]:
root


Out[16]:
<Element '{http://www.naptan.org.uk/}NaPTAN' at 0x19acab1e0>

In [17]:
root.attrib


Out[17]:
{'CreationDateTime': '2015-03-17T09:32:15',
 'FileName': 'NaPTAN.xml',
 'Modification': 'new',
 'ModificationDateTime': '2015-03-17T09:32:15',
 'RevisionNumber': '0',
 'SchemaVersion': '2.1',
 '{http://www.w3.org/2001/XMLSchema-instance}schemaLocation': 'http://www.naptan.org.uk/ http://www.naptan.org.uk/schema/2.1/NaPTAN.xsd'}

In [18]:
root.tag


Out[18]:
'{http://www.naptan.org.uk/}NaPTAN'

In [ ]: