import pickle
import pandas as pd
import numpy as np 

restaurant_list=pickle.load( open( "save_coordinates.p", "rb" ))

mask=np.logical_or( restaurant_list['precise']=='yes', restaurant_list['precise']=='only_plz')

outstring='var markers = [\n'
for index, row in restaurant_list[mask].iterrows():
    message="Address: %s %s %s"%(row['Adresse'], row['PLZ'], row['Ort'])
    if row['precise']=='only_plz':
        message+=". Imprecise location, using only postal code"
    outstring+='''
  {
    "Restaurant" : "%s",
    "message" : "%s",
    "lat" : "%4.6f",
    "lng" : "%4.6f"
  },
'''%(row['Restaurant'], message,row['latitude'],row['longitude'])
outstring=outstring+"];"
out=open("finalversion/markers.js",'w')
out.write(outstring)
out.close()
