-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcitiesConvert.py
32 lines (23 loc) · 952 Bytes
/
citiesConvert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json
import pandas
import sys
from random import randint
output = "var addressPoints = [\n"
with open('largest_cities.json') as f:
data = json.load(f)
packStat = ["0 - Unpacked", "1 - Packed"]
logStat = ["0 - Not Shipped", "1 - In Transit", "2 - Received"]
table = []
for x in data:
lat = json.dumps(x["fields"]["coordinates"][0])
lon = json.dumps(x["fields"]["coordinates"][1])
stat = logStat[randint(0, 2)]
pack = packStat[randint(0, 1)]
output += ("[" + lat + ", " + lon + ", " + "\"" + x["fields"]["city"] + " | Status: " + stat + " | Expiry: 2021-07-07T00:00:00.000Z" + "\"],\n")
table.append([x["fields"]["city"], lat, lon, x["recordid"], pack, stat])
output = output[:-2]
output += '\n];'
df = pandas.DataFrame(table, columns=["city", "latitude", "longitude", "globalLocationNumber", "packStatus", "logisticStatus"])
df.to_html("generatedTable.html", classes="table")
sys.stdout = open('OurData.js', 'w')
print(output)