Untitled
unknown
python
2 years ago
2.0 kB
4
Indexable
Never
from datetime import datetime import pytz import pandas as pd import os import glob regionsDF = pd.read_excel("/content/market_infor.xlsx") boundingBox_list = [list(regionsDF.iloc[i,9:13]) for i in range(55)] API_KEY = "AwpkydowEp2NQDncMwYzbFsoGk07HB8R" requests_list = [] for i in range(len(boundingBox_list)): request = Build_Request_From_MapQuest(API_KEY, boundingBox_list[i][0], boundingBox_list[i][1], boundingBox_list[i][2], boundingBox_list[i][3], []) requests_list.append(request) print(len(requests_list)) print(requests_list) for i in range(18, 55): q = requests_list[i] q = q.replace("&", "\&") s = !curl -X GET $q id = i + 1 df = Incidents_Json_To_DF(s) tz = pytz.timezone('Asia/Saigon') datetime_local = datetime.now(tz) df.to_excel("/content/drive/MyDrive/3rdYear/DuLieuLon/DoAn/MapQuest/Excel/MapQuest_{}_{}_ID{}.xlsx"\ .format(str(datetime_local.date()).replace("-",''), datetime_local.strftime("%H%M"), id), index=False) df.to_csv("/content/drive/MyDrive/3rdYear/DuLieuLon/DoAn/MapQuest/CSV/MapQuest_{}_{}_ID{}.csv"\ .format(str(datetime_local.date()).replace("-",''), datetime_local.strftime("%H%M"), id), index=False) # gop tat ca thanh 1 file files = os.path.join("/content/drive/MyDrive/3rdYear/DuLieuLon/DoAn/MapQuest/CSV/", "*.csv") files = glob.glob(files) df_All = pd.concat(map(pd.read_csv, files), ignore_index=True) tz = pytz.timezone('Asia/Saigon') datetime_local = datetime.now(tz) df_All.to_excel("/content/drive/MyDrive/3rdYear/DuLieuLon/DoAn/MapQuest/Excel/MapQuest_{}_{}_All.xlsx"\ .format(str(datetime_local.date()).replace("-",''), datetime_local.strftime("%H%M")), index=False) df_All.to_csv("/content/drive/MyDrive/3rdYear/DuLieuLon/DoAn/MapQuest/CSV/MapQuest_{}_{}_All.csv"\ .format(str(datetime_local.date()).replace("-",''), datetime_local.strftime("%H%M")), index=False)