text = text.replace('\n', ' ')
if case_number:
lines = textwrap.wrap(text, width=25) # 25
first_line = lines[0]
remainder = ' '.join(lines[1:])
lines = textwrap.wrap(remainder, 25) # 25
lines = lines[:4] # максимальное количество строк, не считая первой..
can.drawString(405, 775, first_line)
for n, l in enumerate(lines, 1):
can.drawString(405, 773 - (n*15), l)
import requests
from multiprocessing.pool import ThreadPool
link = 'https://dsa.court.gov.ua/open_data_json.php?json=532'
response = requests.get(link).json()
urls = []
for item in response['Файли']:
urls.append(list(item.values())[0])
def download_url(url):
print("downloading: ",url)
file_name_start_pos = url.rfind("/") + 1
file_name = url[file_name_start_pos:]
r = requests.get(url, stream=True)
if r.status_code == requests.codes.ok:
with open(file_name, 'wb') as f:
for data in r:
f.write(data)
return url
urls = urls
results = ThreadPool(5).imap_unordered(download_url, urls)
for r in results:
print(r)
with open('Список.csv', 'r', encoding='utf-8') as f:
reader = csv.reader(f, delimiter='\t')
data = []
for row in reader:
if ' ' in row[3]:
data.append({'date':row[0], 'judges':row[1], 'case':row[2],
'court_name':row[3], 'court_room':row[4], 'case_involved':row[5], 'case_description':row[6]})
with open('1new_data.json', 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=7)