import json
# import numpy as np

file = open('./India.geojson')
data = json.load(file)

feature = data['features']
for row in feature:
	temp = {}
	name = row['properties']['NAME_1']
	# temp['id'] = row['properties']['ID_1']
	# name = row['id']
	temp['type'] = 'Feature'
	temp['properties'] = { 'name': name}
	temp['geometry'] = row['geometry']
	# coordinate = np.array(row['geometry']['coordinates']).flatten()
	new_data = {'type': 'FeatureCollection', 'features': [temp]}
	json_data = json.dumps(new_data)
	part = name.lower().split(' ')
	# part = '_'.join(part)
	# print('import',part,'from \'file-loader!./countries/'+name+'.geojson\';')
	# print('\''+name+'\':',part+',')
	# print('\''+name+'\':','\'IN-\'')
	with open(name+'.geojson', 'w') as newfile:
		newfile.write(json_data)
	newfile.close()