Created
June 15, 2018 14:05
-
-
Save luvpreetsingh/7e25eb95585181dffdcb8692c3610928 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from pilot.models import Station | |
from django.contrib.gis.geos import Point | |
cities = ["Chandigarh", "Mumbai", "Ludhiana", "Bangalore", "Goa", "Delhi", "Hyderabad"] | |
cities_dict = { "Chandigarh": { "lat": "30.7", "lon": "76.7" }, "Mumbai": {"lat": "19.0","lon": "76.7" }, "Bangalore": { "lat": "12.9", "lon": "77.5"}, "Ludhiana": {"lat": "30.9", "lon": "75.8"},"Goa": {"lat": "15.2","lon": "74.1"},"Delhi": {"lat": "28.7","lon": "77.1"},"Hyderabad": {"lat": "17.3","lon": "78.4"},} | |
for i in range(1,100000): | |
city = random.choice(cities) | |
code = "{0}-{1}".format(city[:3].upper(), i) | |
name = "{0} {1}".format(code, city) | |
latitude = float(cities_dict[city]["lat"] + str(random.randint(10000, 99999))) | |
longitude = float(cities_dict[city]["lon"] + str(random.randint(10000, 99999))) | |
address = "This is a address field for Station {0}".format(name) | |
location = Point(longitude,latitude) | |
station_data = { 'name' : name, 'city':city, 'code':code, 'location':location, 'address':address} | |
Station.objects.create(**station_data) | |
print('saved - ' + str(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment