Sunday 9 August 2015

Python-CSV Data



Reading and writing comma-separated data

We are going to do some analysis on real life data.

Reading Airport data

Data is present in the below link :
http://openflights.org/data.html and save it as “airports.dat”

Following code will show you the Names of all routes in that file

Airline Route Histogram

Tasks to be completed with the above data :

(I) AIRPORT DATA
Using the "airports.dat" data use the unique ID and map it to the respective geographical coordinates (latitudes and longitudes). With this you can find the location of  the airports.

Reading the data from airports.dat file


Latitudes 


Longitudes


(II)ROUTES AND DISTANCES
Go to the above link and download the “Routes.dat” file.

With the help of the ID of source and destination airport ,look up the coordinates of the airports and calculate the route distances. Based on the latitudes and longitudes we would be able to know the length of the route and append it to the list of all route length.

Geodistance calculation


Download the program from the above link and save it to your local.

Load and run the program.


Now you can import it and fine the geodistance between two airports.


(III)    HISTOGRAM
Plot a histogram based on the route lengths to show the distribution of different flight distances.



                
 Source: http://opentechschool.github.io/python-data-intro/core/csv.html