pool = Pool(size=10)
    pool.add_tasks([ ( getEach, (i, id,))  for i, id in enumerate(id_list)])
    pool.run()

    temp_list = list(pool.output_queue.queue)
    temp_list.sort(key=lambda e: e['編號'])
    data = temp_list

def process():
    global data
    temp_list = []
    for temp in data:
        temp['第一層級'] = '台南市政府'

        temp_list.append(temp)
    data = temp_list

if __name__ == '__main__':
    f_name = '05_tainan'

    # ===== Download or Load data =====
    load()

    # ===== process =====
    getAll()
    process()

    # ===== save =====
    lib.saveCSV(f_name, data)
    lib.saveJSON(f_name, data)
Beispiel #2
0
                temp[org].append(row)

                break
    org_data = temp

    for t in temp:
        print(t, len(temp[t]))

if __name__ == '__main__':
    list_url = 'https://data.gov.tw/datasets/export/csv'
    download_url = 'https://data.gov.tw/statistics/datasets/datasets/export/csv'
    f_name = '16-22_data_gov'

    # ===== Download and Combine =====
    # downloadList(list_url, download_url, f_name)
    # combineCSV(f_name)

    # ===== Load data =====
    load()

    # ===== process =====
    process()

    # ===== save =====
    org_name = ['屏東','基隆','苗栗','彰化','雲林','嘉義','花蓮','連江']
    org_f_name = ['15_pingtung', '16_keelung', '17_miaoli', '18_changhua', '19_yunlin', '20_chiayi_cuntry', '21_hualien', '22_lianjiang']
    for i in range(len(org_f_name)):
        lib.saveCSV(org_f_name[i], org_data[org_name[i]])
        lib.saveJSON(org_f_name[i], org_data[org_name[i]])