Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import os
- import xlwt
- import threading
- def json_to_xls(i):
- wb = xlwt.Workbook()
- ws = wb.add_sheet('sheet 1')
- ws.write(0, 0, 'Type:')
- ws.write(0, 1, 'Project Id:')
- with open(i, 'r', encoding='utf-8') as fh:
- data = json.load(fh)
- l = 1
- for d in data:
- ws.write(l, 0, d.get('type'))
- ws.write(l, 1, d.get('project_id'))
- l += 1
- wb.save(i + '.xls')
- files = os.listdir()
- thread_list = []
- value = 0
- thread_list = []
- for i in files:
- json_file = i.endswith('.json')
- if json_file == True:
- t = threading.Thread(target = json_to_xls, name = value, args = i)
- value += 1
- t.start()
- thread_list.append(t)
- print(i)
- converter_json(i)
- for t in thread_list:
- t.join()
- TypeError: json_to_xls() takes 1 positional argument but 21 were given
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement