-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_state.py
13 lines (11 loc) · 3.63 KB
/
extract_state.py
1
2
3
4
5
6
7
8
9
10
11
12
13
import json
from operator import itemgetter
with open('city.json') as json_data:
city = json.load(json_data)
one = ['Abohar', 'Agartala', 'Agra', 'Ahmadnagar', 'Ahmedabad', 'Ahmednagar', 'Aizawl', 'Ajmer', 'Akola', 'Aligarh', 'Allahabad', 'Allepy', 'Ambala Cantt', 'Amravati', 'Amritsar', 'Anand', 'Anantapur', 'Arrah', 'Asansol', 'Aurangabad', 'Azamgarh', 'Bahadurgarh', 'Baharampur', 'Balasore', 'Balurghat', 'Banda', 'Bangalore', 'Bangalore', 'Bangalore', 'Bankura', 'Baramati', 'Bareilly', 'Barnala', 'Barshi', 'Baruipur', 'Basirhat', 'Basti', 'Batala', 'Bathinda', 'Beawar', 'Begusarai', 'Belgaum', 'Bellary', 'Berhampur', 'Bhagalpur', 'Bharatpur', 'Bhaurach', 'Bhavnagar', 'Bhind', 'Bhiwani', 'Bhopal', 'Bhubaneswar', 'Bid', 'Bihar Shariff', 'Bijapur', 'Bijnor', 'Bikaner', 'Bilaspur', 'Bogra', 'Bokaro', 'Bulandshahar', 'Burdwan', 'Calicut', 'Chandigarh', 'Chandrapur', 'Chapra', 'Chennai', 'Chennai', 'Chhindwara', 'Chittagong', 'Cochin', 'Coimbatore', 'Cooch Bihar', 'Cuttack', 'Daltonganj', 'Davangere', 'Dehradun', 'Delhi', 'Delhi', 'Delhi', 'Delhi', 'Delhi', 'Dhaka', 'Dhaka', 'Dhaka', 'Dhanbad', 'Dharmapuri', 'Dibrugarh', 'Dimapur', 'Durg', 'Durgapur', 'Erode', 'Faizabad', 'Faridabad', 'Faridkot', 'Farrukhabad', 'Firozabad', 'Gandhinagar', 'Gaya', 'Ghaziabad', 'Godhra', 'Gondia', 'Gopalganj', 'Gulbarga', 'Guna', 'Guntur', 'Gurgaon', 'Guwahati', 'Gwalior', 'Habra', 'Haldia', 'Haldwani', 'Hanumangarh', 'Hardwar', 'Hazaribagh', 'Hissar', 'Hoshiarpur', 'Hospet', 'Howrah', 'Hubli', 'Hyderabad', 'Hyderabad', 'Ichalkaranji', 'Indore', 'Itanagar', 'Jabalpur', 'Jaipur', 'Jaisalmer', 'Jalandhar', 'Jalgaon', 'Jalpaiguri', 'Jammu', 'Jamshedpur', 'Jaunpur', 'Jehanabad', 'Jeypur', 'Jhansi', 'Jharsuguda', 'Jhunjhunu', 'Jind', 'Jodhpur', 'Jorhat', 'Kaithal', 'Kakinada', 'Kannur', 'Kanpur', 'Karimnagar', 'Karnal', 'Kashipur', 'Katihar', 'Khammam', 'Khandwa', 'Khanna', 'Khargone', 'Khulna', 'Kolhapur', 'Kolkata', 'Kolkata', 'Kollam', 'Korba', 'Kota', 'Kottayam', 'Kullu', 'Kurnool', 'Kurukshetra', 'Latur', 'Lucknow', 'Ludhiana', 'Madurai', 'Mahesana', 'Mandalay', 'Mandi', 'Mandsaur', 'Mangalore', 'Mapusa', 'Mathura', 'Meerut', 'Moga', 'Mohali', 'Moradabad', 'Motihari', 'Mughalsarai', 'Muktsar', 'Mumbai', 'Mumbai', 'Mumbai', 'Mumbai-Kalyan', 'Munger', 'Muvattupuzha', 'Muzaffarnagar', 'Muzaffarpur', 'Mysore', 'Nagaon', 'Nagercoil', 'Nagpur', 'Nalgonda', 'Namakkal', 'Nanded', 'Nandyal', 'Narnaul', 'Nashik', 'Nellore', 'Mumbai', 'Neyveli', 'Nizamabad', 'Noida', 'Ongole', 'Palakkad', 'Panchkula', 'Panipat', 'Pathanamthitta', 'Pathankot', 'Patiala', 'Patna', 'Pollachi', 'Pondicherry', 'Pudukkottai', 'Pune', 'Purnea', 'Purulia', 'Rae Bareli', 'Raichur', 'Raipur', 'Rajahmundry', 'Rajshahi', 'Rampur', 'Ranchi', 'Ratlam', 'Raxaul Bazar', 'Rewa', 'Rewari', 'Rohtak', 'Roorkee', 'Rourkela', 'Rudrapur', 'Rupnagar', 'Sagar', 'Saharanpur', 'Saharsa', 'Salem', 'Samastipur', 'Sambalpur', 'Sangli', 'Sasaram', 'Satara', 'Satna', 'Serampore', 'Shahjahanpur', 'Shillong', 'Shimla', 'Shimoga', 'Shivpuri', 'Sikar', 'Siliguri', 'Sirsa', 'Sitamarhi', 'Sitapur', 'Siwan', 'Solan', 'Solapur', 'Sonipat', 'Sri Ganganagar', 'Srikakulam', 'Sultanpur', 'Surat', 'Surendranagar', 'Suri', 'Tarn-Taran', 'Tezpur', 'Thanjavur', 'Thrissur', 'Tinsukia', 'Tirunelveli', 'Tirupati', 'Tiruppur', 'Tiruvannamalai', 'Trichy', 'Tumkur', 'Tuticorin', 'Udaipur', 'Udaipur', 'Udupi', 'Ujjain', 'Vadodara', 'Valsad', 'Vapi', 'Varanasi', 'Vidisha', 'Vijayawada', 'Visakhapatnam', 'Warangal', 'Yamunanagar', 'Yavatmal', ]
for i in one:
try:
index_value = map(itemgetter('name'), city).index('{}'.format(i))
print city[index_value]['state']
except ValueError:
print "NIL"